'Unable to use Bokeh plot's 'desired_num_ticks'. Error thrown is " 'NoneType' object has no attribute 'desired_num_ticks' "
As per this document I understand that 'desired_num_ticks' is not deprecated and that it expects an integer.
https://docs.bokeh.org/en/latest/docs/reference/models/tickers.html
But I get error for the below plot. (Please note, when I comment ' f.ygrid[0].ticker.desired_num_ticks = 1 ', everything works fine and I get the Bokeh plot)
print(df) # the data that i'm using
Start End
0 2020-06-14 11:30:05.940200 2020-06-14 11:30:06.244248
1 2020-06-14 11:30:06.276542 2020-06-14 11:30:06.371198
2 2020-06-14 11:30:06.516061 2020-06-14 11:30:06.547580
3 2020-06-14 11:30:06.579995 2020-06-14 11:30:06.612236
4 2020-06-14 11:30:06.644278 2020-06-14 11:30:06.676330
5 2020-06-14 11:30:10.243353 2020-06-14 11:30:10.755898
from detection1dot2 import df # import the dataframe
from bokeh.plotting import figure, show, output_file
f=figure(x_axis_type='datetime', height=500, width=500, sizing_mode="stretch_width", title='Motion Graph')
f.yaxis.minor_tick_line_color = None
f.ygrid[0].ticker.desired_num_ticks = 1
f.quad(left=df["Start"], right=df["End"], bottom=0, top=1)
output_file("motion.html")
When I run the script I get the below error.
f.ygrid[0].ticker.desired_num_ticks = 1
AttributeError: 'NoneType' object has no attribute 'desired_num_ticks'
Solution 1:[1]
Instead of
f.ygrid[0].ticker.desired_num_ticks = 1
Use
f.ygrid.ticker = [0,1] # pass a list of desired ticks
It will work
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Flair |
