Prithvee
Prithvee

Reputation: 71

Using a For Loop to generate scatter plots on Bokeh (with Pandas dataframe)

I am trying to generate scatter plots using bokeh and saving into a html file. The number of subplots I am making is a non-constant number and I cannot use p1=figure(...) p2=figure(...) in bokeh. I am looking for an equivalent bokeh code for the pyplot code below,

for i,j in df.groupby("IO"):        
    j.plot(kind='scatter',x='row_mod256',y='BitsAffected',edgecolors='r',s=5)
    plt.title(i)

plt.show()

Basically I want to merge multiple html files (plots) generated using bokeh to one html file where the number of plots changes with entries and is not constant. Can someone please help?

Upvotes: 0

Views: 1193

Answers (1)

bigreddot
bigreddot

Reputation: 34568

To collect multiple plots in one HTML file, assemble the plots in a layout and show that at the end:

plots = []
for i,j in df.groupby("IO"):    
    p = figure(...)
    p.circle(...)

    plots.append(p)

show(column(*plots))

Upvotes: 1

Related Questions