0
votes

I am modifying an existing category chart's vertical value axis title.

I can successfully modify the value axis title text using the following code:

S2_L_chart= prs.slides[slide_index].shapes[3].chart #select chart
S2_L_chart.value_axis.has_title= False #clear axis title
S2_L_chart.value_axis.axis_title.text_frame.text= "pokemon" #modify axis title

Unfortunately, I lose my text formatting (it defaults to bold). I am attempting to "unbold" it with the following setting (and variations).

S2_L_chart.value_axis.axis_title.text_frame.font.bold= None

I receive the following error:

Traceback (most recent call last):
  File "FILEPATH/filename.py", line 61, in <module>
    S2_L_chart.value_axis.axis_title.text_frame.font.bold= None
AttributeError: 'TextFrame' object has no attribute 'font'

What is the correct code to access the bold attribute on a value axis?

Thank you.

2

2 Answers

0
votes

This does the trick:

S2_L_chart.value_axis.axis_title.text_frame.paragraphs[0].runs[0].font.bold= False
0
votes

If you skip the clear formatting step, it will retain the bold/unbold of the original chart formatting.

remove:

S2_L_chart.value_axis.has_title= False #clear axis title