When creating a plot with a logarithmic scale on the x-axis, if the maximum x-value is less than 1 the x-axis decreases from left to right, the scale is linear, not logarithmic, and the default view does not show the data. I tested various values for the maximum x-value and found that when x_max > 1, the x-axis increases left to right but the default view only shows x > 1. This code demonstrates the problem
import numpy as np
from bokeh.plotting import figure, output_file, show
output_file('test.html')
x = np.linspace(0, 0.95) # x decreases left to right, linear scale
# x = np.linspace(0, 1) # x increases left to right but default view shows, 1 < x < 1.05
# x = np.linspace(0, 10) # x increases left to right but default view shows, 1 < x < 10.5
y = np.sin(x)/x
p = figure(x_axis_type='log')
p.line(x, y)
show(p)
I tried declaring the x_range for the figure using x_range=(x.min(), x.max()) but this had to effect unless I removed the zero point from the data, i.e., x = x[x > 0]. With theses changes, the x-axis increases left to right and the default view shows the range indicated. Here is a functional workaround
import numpy as np
from bokeh.plotting import figure, output_file, show
output_file('test.html')
x = np.linspace(0, 0.95) # x decreases left to right, linear scale
x = x[x > 0]
y = np.sin(x)/x
p = figure(x_axis_type='log', x_range=(x.min(), x.max()))
p.line(x, y)
show(p)
I did not test all these same conditions with y_axis_type but I expect it to have the same problems. I did notice that the default view only shows y > 1, even if the data begins ay y < 1.
Here are the key points that need to be verified for logarithmic x and y axes:
When creating a plot with a logarithmic scale on the x-axis, if the maximum x-value is less than 1 the x-axis decreases from left to right, the scale is linear, not logarithmic, and the default view does not show the data. I tested various values for the maximum x-value and found that when x_max > 1, the x-axis increases left to right but the default view only shows x > 1. This code demonstrates the problem
I tried declaring the x_range for the figure using
x_range=(x.min(), x.max())but this had to effect unless I removed the zero point from the data, i.e.,x = x[x > 0]. With theses changes, the x-axis increases left to right and the default view shows the range indicated. Here is a functional workaroundI did not test all these same conditions with
y_axis_typebut I expect it to have the same problems. I did notice that the default view only showsy > 1, even if the data begins ayy < 1.Here are the key points that need to be verified for logarithmic x and y axes: