0

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.

user2529589
  • 330
  • 4
  • 16
  • 1
    Refer to: https://python-pptx.readthedocs.io/en/latest/user/text.html#applying-character-formatting – ycx Aug 16 '19 at 02:10

2 Answers2

0

This does the trick:

S2_L_chart.value_axis.axis_title.text_frame.paragraphs[0].runs[0].font.bold= False
user2529589
  • 330
  • 4
  • 16
0

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
user2529589
  • 330
  • 4
  • 16