Reputation: 2041
My code is below. How can I get a log scale for a bokeh hbar plot? Tried x_axis_type="log"
, but that returned an empty plot.
Edit: I was advised that I must set left
to a low but non-zero value in order for it to work, but the new addition left = 0.001
in the code below seem to offset the zero point of the bars on the left, but does not appear as a desired log-scale where the difference between the extreme value in x
is visualised as less visually extreme.
Edit (solved): My error in the edit above was that I had not explicitly set the range of the bars. I added x_range=[0.001,1000000]
to the code below, and now I get the desired result. See image.
from bokeh.plotting import figure
from bokeh.io import show, output_notebook
output_notebook()
x = [1,5,9,256000]
y = ["a","b","c","d"]
p = figure(y_range=y,x_axis_type = "log",x_range=[0.001,1000000])
p.hbar(y = y, right = x, left = 0.001, height = 0.1)
show(p)
Upvotes: 0
Views: 364
Reputation: 34568
Zero is not a permissible value on a log scale, and as of version 2.3.1 Bokeh does not have anything like Matplotlib's symlog
scale that linearizes around the origin. The best you will be able to to is to set left
equal to some very small value (but non-zero).
Upvotes: 1