word wrap data labels python-pptx

北城余情 提交于 2020-04-14 07:02:08

问题


Is it possible to set word wrap to false all data labels in my chart?

I was trying to do plots[0].data_labels.format.text_frame.word_wrap = False but data_labels hasn't format property


回答1:


Start with the DataLabels object. This is available on the .data_labels attribute of a plot or a series. You might want to try both to see what behavior you get:

from pptx.text.text import TextFrame

# ---obtain reference to <c:dLbls> element in question---
data_labels = plot2.data_labels
dLbls = data_labels._element
# ---use its <c:txPr> child to create TextFrame object---
text_frame = TextFrame(dLbls.get_or_add_txPr(), None)
# ---turn off word-wrap in the usual way---
text_frame.word_wrap = False

This can be made more compact, I show it step-by-step here for clarity.



来源:https://stackoverflow.com/questions/54353954/word-wrap-data-labels-python-pptx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!