简体   繁体   English

Python XlsxWriter 图表:x 轴值标签角度方向

[英]Python XlsxWriter chart : x-axis value labels angle orientation

I have just discovered the website for the Python API : XlsxWriter.我刚刚发现了 Python API 的网站:XlsxWriter。 I am specifically looking at the Chart creation aspect.我特别关注图表创建方面。 I found an example with Date type on the x-axis and in the example the dates are oriented 45 deg with respect to the horizontal: http://xlsxwriter.readthedocs.org/example_chart_date_axis.html我在 x 轴上找到了一个 Date 类型的例子,在这个例子中,日期相对于水平方向成 45 度: http : //xlsxwriter.readthedocs.org/example_chart_date_axis.html

But, when I look at the code below it, I do not see reference to how to control the angle.但是,当我查看它下面的代码时,我没有看到如何控制角度的参考。 For example if I wanted the dates oriented at 30 degrees instead.例如,如果我想要以 30 度为方向的日期。

Is there a function or method that controls the orientation such that a programmer can specify the desired angle?是否有控制方向的函数或方法,以便程序员可以指定所需的角度?

I found this article on Stack Overflow: Modify chart label orientation with XlsxWriter module (Python) .我在 Stack Overflow 上找到了这篇文章: 使用 XlsxWriter 模块 (Python) 修改图表标签方向 The developer mentions "Chart axis font orientation", but I am not sure if this is what controls the date labels on the x-axis.开发人员提到了“图表轴字体方向”,但我不确定这是否是控制 x 轴上日期标签的原因。

I do not see reference to how to control the angle.我没有看到如何控制角度的参考。 For example if I wanted the dates oriented at 30 degrees instead.例如,如果我想要以 30 度为方向的日期。

Excel rotates date values automatically when necessary (which is the case in the example that you linked to). Excel 会在必要时自动旋转日期值(在您链接到的示例中就是这种情况)。

However, you can control the rotation yourself as a font property (like in Excel):但是,您可以自己控制旋转作为字体属性(如在 Excel 中):

chart.set_x_axis({'num_font':  {'rotation': 45}})

See the Chart Fonts section of the docs.请参阅文档的图表字体部分。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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