python - xaxis.major_label_orientation 用于 Bokeh 条

标签 python bokeh

在常规(低级)绘图中,可以像这样设置标签方向:

p.xaxis.major_label_orientation = pi/4

根据http://docs.bokeh.org/en/0.9.3/docs/user_guide/styling.html#tick-label-orientation

我想在 bokeh.charts.Bar 中将 x 轴标签方向设置为“水平”,但找不到执行此操作的方法。

Bokeh 0.9.3。

最佳答案

bokeh.charts API 已于 2017 年弃用并删除,目前不应用于任何用途。

从那时起,Bokeh 在得到良好支持的 bokeh.plotting API 中对分类图和条形图的支持已经变得非常好。现在可以以标准方式旋转条形图上的轴标签:

from math import pi
from bokeh.plotting import figure, show

types = list("ABCDE")
values = [10, 20, 50, 25, 35]

p = figure(x_range=types, plot_height=250)
p.vbar(x=types, top=values, width=0.9)

p.xaxis.major_label_orientation = pi/4   # standard styling code

show(p)

enter image description here

您可以在Handling Categorical Data中找到更多信息和示例。用户指南的部分。

关于python - xaxis.major_label_orientation 用于 Bokeh 条,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39298411/

相关文章:

Bokeh :模型只能由一个文档所有

python - 查找特定的顺序模式

python - Scikit-学习 TransformerMixin : 'numpy.ndarray' object has no attribute 'fit'

python - 使用 asyncio 的简单非阻塞无限循环

python - Bokeh 逐年折线图程序

python - Bokeh DataRange1d 慢慢移出屏幕

python - 用于改变 Bokeh 图像图中使用的切片的交互式 slider

python - Pandas:从函数连续写入 csv

python - 如何使用Python库读取稀疏ARFF数据?

python-3.x - 在 Flask 中调制 Bokeh 服务器