Bokeh标签在x轴上截断
我用Bokeh创建了一个图表,其中X轴的类型为“datetime”。 不幸的是,X轴上显示的标签被截断。 如何防止这种截断 这是我的代码:Bokeh标签在x轴上截断,bokeh,Bokeh,我用Bokeh创建了一个图表,其中X轴的类型为“datetime”。 不幸的是,X轴上显示的标签被截断。 如何防止这种截断 这是我的代码: TOOLS = "pan,wheel_zoom,box_zoom,reset,save" p = figure(x_axis_type="datetime", tools=TOOLS, plot_width=1000, plot_height=600, title = "Feed") p.xaxis.formatter=DatetimeTickFormat
TOOLS = "pan,wheel_zoom,box_zoom,reset,save"
p = figure(x_axis_type="datetime", tools=TOOLS, plot_width=1000, plot_height=600, title = "Feed")
p.xaxis.formatter=DatetimeTickFormatter(
hours=["%d %B %Y"],
days=["%d %B %Y"],
months=["%d %B %Y"],
years=["%d %B %Y"],
)
p.grid.grid_line_alpha=0.3
p.line(_df.datetime, [i for i in range(len(_df.datetime))], color='firebrick', legend='Fast Ask')
output_file("bokeh.html", title="example")
output_notebook()
show(p) # open a browser
这是图表:
谢谢,
杰拉尔德来自:
DatetimeTickFormatter具有以下属性(与其默认值一起列出),可用于控制不同比例下轴标记的格式:
microseconds = ['%fus']
milliseconds = ['%3Nms', '%S.%3Ns']
seconds = ['%Ss']
minsec = [':%M:%S']
minutes = [':%M', '%Mm']
hourmin = ['%H:%M']
hours = ['%Hh', '%H:%M']
days = ['%m/%d', '%a%d']
months = ['%m/%Y', '%b%y']
years = ['%Y']
您只需设置最后四个刻度,从
小时开始。但从您的图片可以清楚地看到,x轴范围仅扩展到分钟刻度,因此Bokeh使用的是分钟刻度的默认格式,如上图所示。如果您想为较小的刻度(例如,hourmin
和minutes
或更小的刻度)设置“完整”标签,那么在创建DatetimeTickFormatter
时,您也需要对其进行配置,谢谢!