在代码中,我试图在Web浏览器中打印3个图,但是仅打印2个图(high2和high3)。你能告诉我如何得到所有三个地块吗?谢谢
#Plot 1
for index, row in Taskee_assi.iterrows():
new_list1.append(row.AddDateTimeInUTC_x.hour)
plt.title("Overall Tasks assigned WRT Time")
plt.hist(new_list1, bins=50)
high1 = plt.figure()
list_sum_1 = sum(new_list1)
list_num_1 = len(new_list1)
list_avg1 = list_sum_1/list_num_1
print('Average of Overall Tasks Assigned wrt Time',list_avg1)
#Plot 2
for index,row in dummy_var2.iterrows():
new_list2.append(row.EventDateTimeInUTC.hour)
plt.title("Time at which Task is read ")
plt.hist(new_list2, bins=50)
high2 = plt.figure()
list_sum_2 = sum(new_list2)
list_num_2 = len(new_list2)
list_avg2 = list_sum_2/list_num_2
print('Average Time in which Tasks are read',list_avg2)
#Plot 3
for index,row in dummy_var4.iterrows():
new_list3.append(row.EventDateTimeInUTC.hour)
plt.title("Time at which Comments are read ")
plt.hist(new_list3, bins=50)
high3 = plt.figure()
list_sum_3 = sum(new_list3)
list_num_3 = len(new_list3)
list_avg3 = list_sum_3/list_num_3
print('Average Time in which Comments are read (in terms of time)',list_avg3)
html1 = mpld3.fig_to_html(high1)
html2 = mpld3.fig_to_html(high2)
html3 = mpld3.fig_to_html(high3)
serve(html1+html2+html3)
答案 0 :(得分:0)
我找到了另一个答案。我为该图创建了子图,然后在浏览器中显示了该图。使用此方法,可以在网络浏览器中显示任意数量的图。
for index, row in Taskee_assi.iterrows():
new_list1.append(row.AddDateTimeInUTC_x.hour)
#For Subplot 1.1
list_sum_1 = sum(new_list1)
list_num_1 = len(new_list1)
list_avg1 = list_sum_1/list_num_1
print('Average of Overall Tasks Assigned wrt Time',list_avg1)
for index,row in dummy_var2.iterrows():
new_list2.append(row.EventDateTimeInUTC.hour)
#For Subplot 1.2
list_sum_2 = sum(new_list2)
list_num_2 = len(new_list2)
list_avg2 = list_sum_2/list_num_2
print('Average Time in which Tasks are read',list_avg2)
for index,row in dummy_var4.iterrows():
new_list3.append(row.EventDateTimeInUTC.hour)
#For Subplot 1.3
list_sum_3 = sum(new_list3)
list_num_3 = len(new_list3)
list_avg3 = list_sum_3/list_num_3
print('Average Time in which Comments are read ',list_avg3)
f, (ax1, ax2, ax3) = plt.subplots(3,figsize=(10,10))
ax1.hist(new_list1, bins=50)
ax1.set_title("Overall Tasks assigned WRT Time")
ax2.hist(new_list2, bins=50)
ax2.set_title("Time at which Task is read ")
ax3.hist(new_list3, bins=50)
ax3.set_title("Time at which Comments are read ")
f.subplots_adjust(top=0.90, bottom=0.08, left=0.10, right=0.95, hspace=0.55,wspace=0.35)
plt.setp([a.get_xticklabels() for a in f.axes[:0]], visible=False)
html1 = mpld3.fig_to_html(f)