【发布时间】:2021-08-20 15:52:07
【问题描述】:
我不知道为什么,当我尝试将 x 轴标签方向更改为“垂直”时,输出文件显示为空白,而之前它运行良好:
import pandas as pd
from bokeh.io import show, output_file
from bokeh.plotting import figure
from bokeh.models import ColumnDataSource
output_file("average_conso_cpu.html")
average_cpu_data = pd.read_csv(r"average_cpu_hours.csv", sep=';')
filtered_data = average_cpu_data.head(10)
source = ColumnDataSource(filtered_data)
payoffs = source.data['payoffname'].astype(str)
cpu_hours = source.data['avg_mc_cpu_hours']
p = figure(x_range=payoffs, plot_height=250, title="Payoffs")
p.left[0].formatter.use_scientific = False
p.vbar(x=payoffs, top=cpu_hours, width=0.9)
p.xaxis.major_label_orientation = "vertical"
p.xgrid.grid_line_color = None
p.y_range.start = 0
show(p)
这行有问题:
p.xaxis.major_label_orientation = "vertical"
与此替代代码相同:
p.xaxis.major_label_orientation = math.pi/2
【问题讨论】:
-
我试图运行您的代码进行调查,结果发现它依赖于外部数据。请更新您的问题以获得完整、独立的Minimal Reproducible Example
-
我要显示的变量名称太长,我删除了绘图的高度限制 (plot_height=250),它现在可以工作了。
-
很高兴您发现了问题!请自行回答以帮助保持散景整洁。