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

1.1k views Asked by At

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?

1

There are 1 answers

0
bigreddot On

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