简体   繁体   English

python散景图如何格式化轴显示

[英]python bokeh plot how to format axis display

the y axis ticks seem to be formatting numbers like 500000000 to 5.000e+8. y轴刻度似乎是格式化数字,如500000000到5.000e + 8。 Is there a way to control the display so that it displays as 500000000? 有没有办法控制显示器,使其显示为500000000?

using python 2.7, bokeh 0.5.2 使用python 2.7,散景0.5.2

im trying out the timeseries example at bokeh tutorials page 我在散景教程页面尝试时间序列示例

The tutorial plots 'Adj Close' against 'Date' but i'm plotting with 'Volume' against 'Date' 该教程将'Adj Close'与'Date'进行对比,但我正在用'Volume'对'Date'进行绘图

You can also use NumeralTickFormatter as used in the toy plot below. 您还可以使用下面玩具图中使用的NumeralTickFormatter。 The other possible values in place of '00' are listed here . 此处列出了代替'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)

You have to add the option p.left[0].formatter.use_scientific = False to your code. 您必须在代码中添加选项p.left[0].formatter.use_scientific = False In the timeseries tutorial, it'd be: 在时间序列教程中,它是:

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM