python - Plot semilogx with matplotlib then convert it into Bokeh -
i plot figure containing several curves using matplotlib , try convert bokeh:
import numpy np import matplotlib.pyplot plt bokeh import mpl bokeh.plotting import show, output_file num_plots = 6 colormap = plt.cm.gist_ncar time = np.random.random_sample((300, 6)) s_strain = np.random.random_sample((300, 6)) def time_s_strain_bokeh(num_plots, colormap, time, s_strain): plt.gca().set_color_cycle([colormap(i) in np.linspace(0, 0.9, num_plots)]) plt.figure(2) in range(0, num_plots): plt.plot(time[:,i], s_strain[:,i]) plt.grid(true) # save bokeh output_file('anywhere.html') show(mpl.to_bokeh()) time_s_strain_bokeh(num_plots, colormap, time, s_strain)
it works fine. however, want have semilogx plot. when change plt.plot
in "for" loop plt.semilogx
, have following error:
unboundlocalerror: local variable 'laxis' referenced before assignment
what can change x-axis onto log scale?
as of bokeh 0.12
, partial , incomplete mpl compatibility provided third party mplexporter
library, appears unmaintained. full (or @ least, more complete) mpl compat support not happen until mpl team implements mep 25. however, implementing mep 25 mpl project task, , timeline/schedule entirely outside of control of bokeh project.
the existing mpl compat based on mplexporter
provided "as-is" in case useful in subset of simple situations works for. suggestion use native bokeh apis directly of moderate complexity.
you can find example of semilog plot created using bokeh apis here:
http://bokeh.pydata.org/en/latest/docs/user_guide/plotting.html#log-scale-axes
Comments
Post a Comment