[英]python bokeh plot how to format axis display
y軸刻度似乎是格式化數字,如500000000到5.000e + 8。 有沒有辦法控制顯示器,使其顯示為500000000?
使用python 2.7,散景0.5.2
我在散景教程頁面嘗試時間序列示例
該教程將'Adj Close'與'Date'進行對比,但我正在用'Volume'對'Date'進行繪圖
您還可以使用下面玩具圖中使用的NumeralTickFormatter。 此處列出了代替'00'的其他可能值。
import pandas as pd
import numpy as np
from bokeh.plotting import figure, output_file, show
from bokeh.models import NumeralTickFormatter
df = pd.DataFrame(np.random.randint(0, 90000000000, (10,1)), columns=['my_int'])
p = figure(plot_width=700, plot_height=280, y_range=[0,100000000000])
output_file("toy_plot_with_commas")
for index, record in df.iterrows():
p.rect([index], [record['my_int']/2], 0.8, [record['my_int']], fill_color="red", line_color="black")
p.yaxis.formatter=NumeralTickFormatter(format="00")
show(p)
您必須在代碼中添加選項p.left[0].formatter.use_scientific = False
。 在時間序列教程中,它是:
p1 = figure(title="Stocks")
p1.line(
AAPL['Date'],
AAPL['Adj Close'],
color='#A6CEE3',
legend='AAPL',
)
p1.left[0].formatter.use_scientific = False # <---- This forces showing 500000000 instead of 5.000e+8 as you want
show(VBox(p1, p2))
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.