[英]Remove bold from existing category chart vertical value axis title with python-pptx
我正在修改现有类别图表的垂直值轴标题。
我可以使用以下代码成功修改值轴标题文本:
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
不幸的是,我失去了文本格式(默认为粗体)。 我正在尝试使用以下设置(和变体)将其“展开”。
S2_L_chart.value_axis.axis_title.text_frame.font.bold= None
我收到以下错误:
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'
在值轴上访问粗体属性的正确代码是什么?
谢谢。
这可以解决问题:
S2_L_chart.value_axis.axis_title.text_frame.paragraphs[0].runs[0].font.bold= False
如果您跳过清除格式设置步骤,它将保留原始图表格式的粗体/粗体。
去掉:
S2_L_chart.value_axis.has_title= False #clear axis title
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.