How do I get log scales when using Bokeh's scatter
function. I'm looking for something like the following:
scatter(x, y, source=my_source, ylog=True)
or
scatter(x, y, source=my_source, yscale='log')
Something along these lines will work:
import numpy as np
from bokeh.plotting import *
N = 100
x = np.linspace(0.1, 5, N)
output_file("logscatter.html", title="log axis scatter example")
figure(tools="pan,wheel_zoom,box_zoom,reset,previewsave",
y_axis_type="log", y_range=[0.1, 10**2], title="log axis scatter example")
scatter(x, np.sqrt(x), line_width=2, line_color="yellow", legend="y=sqrt(x)")
show()
Alternative you can also pass the "log"-related parameters in the scatter call instead of figure (but I recommend you to write it as I showed above):
scatter(x, np.sqrt(x), y_axis_type="log", y_range=[0.1, 10**2], line_width=2, line_color="yellow", legend="y=sqrt(x)")
Hope it helps! ;-)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With