0

In the code I am trying to print 3 plots in the web browser but only 2 of the plots(high2 and high3) are printing. Can you tell me how to get all the 3 plots? Thanks

#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)

1 Answers1

0

I found an alternative answer. I created subplots for the figure and then I'm displaying the same in the browser. Using this method any number of plots can be displayed in the web browser.

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)