Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

word wrap data labels python-pptx

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

like image 583
Marcos Augusto Avatar asked Sep 27 '26 06:09

Marcos Augusto


1 Answers

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.

like image 76
scanny Avatar answered Sep 30 '26 04:09

scanny



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!