简体   繁体   English

如何使用openpyxl设置图表标签的间隔单位

[英]How to set Interval Unit of chart label using openpyxl

I am trying to set Interval Unit (for interval between labels) of chart using openpyxl. 我正在尝试使用openpyxl设置图表的间隔单位(用于标签之间的间隔)。 This option is set to 'Automatic' by default. 默认情况下,此选项设置为“自动”。 Image shows how we can set the option manually in Excel. 该图显示了我们如何在Excel中手动设置选项。 Image Link 图片链接

I found this option in XlsxWriter: 我在XlsxWriter中找到了这个选项:

chart.set_x_axis({'interval_unit': 5})

but could not find the option in openpyxl. 但在openpyxl中找不到该选项。 Please help. 请帮忙。

For bar and column charts in openpyxl the axis labeling individual data is of type openpyxl.chart.axis.TextAxis . 对于openpyxl中的条形图和柱形图,标记单个数据的轴的类型为openpyxl.chart.axis.TextAxis TextAxis features a property named tickLblSkip which defines what you are looking for. TextAxis具有一个名为tickLblSkip的属性,该属性定义了您要查找的内容。 You can set a labeling interval of 5 as follows: 您可以将标签间隔设置为5,如下所示:

from openpyxl.chart import BarChart

chart = BarChart
chart.x_axis.tickLblSkip = 5

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

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