通过for循环绘制子图

时间:2018-10-04 22:18:35

标签: python plotly

我试图在同一行中显示两个条形图,但仅显示一个。

这里是带有键/标签的字典,用于将每个跟踪附加到列表中。

tagged_form = ['count_CC', 'count_DT', 'count_NNP', 'count_PDT','count_POS', 'count_PRP',
               'count_RBR', 'count_RBS', 'count_SYM','count_UH', 'count_WP$', "count_adjectives"]
tagged_label = ["Conjonction de Coordination", "Déterminant", "Nom propre", "Pré-déterminant", "terminaison possessive", 
               "Pronom personel", "Adverbe comparative", "Adverbe Surperlatif", "Symbole", "Interjection", "Pronom Possessive", "Adjectives"]
tagged_dict = dict(zip(tagged_label, tagged_form))
verbal_form = ["vocab_richness", "lexical_diversity", "count_VB", "count_VBD", "count_VBG",  "count_VBN", "is_modal"]
verbal_label = ["Richesse du Vocabulaire", "Diversité Lexical", "Nombre de verbe", "Passé", "participe présent(gérondif)", "participe passé", "Modaux"]
verbal_dict = dict(zip(verbal_label, verbal_form))

tagged_data = []
for k,v in tagged_dict.items():
    tag_trace = go.Bar(x=threat_df[v], name = str(k), opacity = 0.7)
    tagged_data.append((tag_trace))

verbal_data = []
for k,v in verbal_dict.items() :
    trace = go.Bar(x=threat_df[v], name = str(k), opacity = 0.7)
    verbal_data.append(trace) 

fig = tls.make_subplots(rows=1, cols=2,)
fig['data'] = Data(verbal_data + tagged_data)
fig['layout'].update(title="test")
iplot(fig)

0 个答案:

没有答案