簡體   English   中英

散景圖的 X 和 Y 軸標簽

[英]X and Y axis labels for Bokeh figure

有誰知道如何為散景圖添加 x 和 y 軸標題/標簽? 例如 X 軸:時間,Y 軸:股票價格。

非常感謝!

從 Bokeh 0.11.1 開始, 關於軸用戶指南部分現在顯示了如何編輯現有軸的屬性。 方法和之前一樣:

p = figure(width=300, height=300, x_axis_label='Initial xlabel')
p.xaxis.axis_label = 'New xlabel'

看看這個例子: elements.py

您現在還可以為調用figure(...)而不是渲染器函數(在該示例中為circle figure(...)提供與繪圖相關的一般選項( plot_widthtitle等)

這是使用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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM