[英]X and Y axis labels for Bokeh figure
有誰知道如何為散景圖添加 x 和 y 軸標題/標簽? 例如 X 軸:時間,Y 軸:股票價格。
非常感謝!
看看這個例子: elements.py
您現在還可以為調用figure(...)
而不是渲染器函數(在該示例中為circle
figure(...)
提供與繪圖相關的一般選項( plot_width
、 title
等)
這是使用CustomJS
更改軸標簽的方法:
p = figure(x_axis_label="Initial y-axis label",
y_axis_label="Initial x-axis label")
# ...
# p.xaxis and p.yaxis are lists. To operate on actual the axes,
# we need to extract them from the lists first.
callback = CustomJS(args=dict(xaxis=p.xaxis[0],
yaxis=p.yaxis[0]), code="""
xaxis.axis_label = "Updated x-axis label";
yaxis.axis_label = "Updated y-axis label";
""")
from bokeh.plotting import figure, output_file, show
from bokeh.models.annotations import Title
p = figure(plot_width=1300, plot_height=400,x_axis_type="datetime")
p.xaxis.axis_label = 'Time'
p.yaxis.axis_label = 'Stock Price'
p.line(time,stock_price)
t = Title()
t.text = 'Stock Price during year 2018'
p.title = t
show(p)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.