python - 散景:当 x 轴标签垂直时无法显示条形图
问题描述
我不知道为什么,当我尝试将 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
解决方案
我已经解决了我的问题。我的图没有显示,因为我配置了一个绘图高度并且它太小(plot_height=250)。如果你有同样的问题,有两种选择:
- 去掉高度
- 增加高度
推荐阅读
- javascript - 无法从 JS AJAX 将数据发送回 Django
- javascript - 定义数组中的数据
- javascript - phonegap 的 nfc 插件对象在我的一个 javascript 文件中抛出异常
- postgresql - 如何忽略更新查询中的错误?
- webpack - Webpack 4 静态资产不使用 HtmlWebpackPlugin 重新加载
- javascript - 单击搜索输入时Android键盘出现和消失
- django - 在 django 中快速填写表格
- oracle - SoapUI JDBC 连接问题与密码
- java - 关闭应用程序而不是转到上一个活动
- c# - 如何使用 Partner.wsdl 获取 Salesforce 实体的字段列表