Python XlsxWriter 图表 : x-axis value labels angle orientation

标签 python charts xlsxwriter

我刚刚发现了 Python API 的网站:XlsxWriter。 我特别关注图表创建方面。我在 x 轴上找到了一个日期类型的示例,在示例中,日期相对于水平方向为 45 度角: http://xlsxwriter.readthedocs.org/example_chart_date_axis.html

但是,当我查看它下面的代码时,我没有看到如何控制角度的引用。例如,如果我想要将日期定向为 30 度。

是否有控制方向的函数或方法,以便程序员可以指定所需的角度?

我在 Stack Overflow 上找到了这篇文章: Modify chart label orientation with XlsxWriter module (Python) .开发人员提到“图表轴字体方向”,但我不确定这是否控制了 x 轴上的日期标签。

最佳答案

I do not see reference to how to control the angle. For example if I wanted the dates oriented at 30 degrees instead.

Excel 会在必要时自动轮换日期值(在您链接到的示例中就是这种情况)。

但是,您可以将旋转作为字体属性自行控制(如在 Excel 中):

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

参见 Chart Fonts文档部分。

关于Python XlsxWriter 图表 : x-axis value labels angle orientation,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28620658/

相关文章:

python - django-autocomplete-light error = 'list' 对象没有属性 'queryset'

如果没有传递命令行参数,Python 默认参数

c# - 突出显示 Asp.net 图表控件系列中的一列

python - 使用 Matplotlib 绘制条形图

excel - xlsxwriter 在 "thisworkbook"添加一个宏以在打开时执行

pandas - 为什么使用 "to_excel"保存时 Pandas 数据框样式丢失?

python - 使用索引查找带连字符的单词

python - shlex.split() 和 re.split() 有什么区别?

ajax - Google Chart - 从 Google Sheet 刷新数据,无需刷新页面

python - pandas xlsxwriter,格式表标题 - 不是工作表标题