I intend to create the following chart using Python PPTX.
下面的代码实现了颜色设置、字体大小和数字格式。但是,我还无法旋转数据标签,因为我相信此 API 在 python-pptx 0.6.5 中尚不可用
lbl = plot.data_labels
lbl.font.size = config["DATA_LABEL_FONT_SIZE"]
lbl.font.color.rgb = config["DATA_LABEL_FONT_COLOR"]
lbl.number_format = config["DATA_LABEL_NUMBER_FORMAT"]
lbl.position = config["DATA_LABEL_POSITION"]
首先,我在旋转前后创建了两张最小的幻灯片,并使用 opc-diag 工具来查找差异。
<a:bodyPr rot="-5400000" spcFirstLastPara="1" vertOverflow="ellipsis"
vert="horz" wrap="square" lIns="38100" tIns="19050" rIns="38100"
bIns="19050" anchor="ctr" anchorCtr="1">\n
<a:spAutoFit/>\n </a:bodyPr>\n
我相信我需要添加rot="-5400000"
XML 元素到lbl
(plot.data_labels),但不清楚如何实现这一点。我用过dir()
, ._element
and .xml
在图表及其子图表上但找不到<a:bodyPr>
tag.
我在下面尝试过并且有效。
if config["DATA_LABEL_VERTICAL"]:
txPr = lbl._element.get_or_add_txPr()
txPr.bodyPr.set('rot','-5400000')
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)