简体   繁体   中英

How to Change TickLabelSpacing in python pptx

I'm trying to figure out how to change the number of labeled ticks on a python pptx category axis. I can see this note:

To change the number of unlabeled tick marks between tick-mark labels, you must change the TickLabelSpacing property for the category axis.

here: https://python-pptx.readthedocs.io/en/latest/dev/analysis/cht-tick-labels.html

But I can't find any other reference to the attribute in the axis object. Any help here would be great.

Without being able to amend the TickLabelSpacing, I had a rough workaround of removing the values from the label column from my dataframe when creating the chart. In my case the category axis were dates -

chart_data = ChartData()
chart_data.categories = [pd.to_datetime(x).strftime('%d %b %y') if (pd.to_datetime(x).day == 1 or pd.to_datetime(x).day == 15) else '' for x in df['date']]
chart_data.add_series('', (df['volume']))

This gave dates on the category axis only for the 1st and 15th of the month.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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