Closed vba34520 closed 3 years ago
from pptx.util import Inches
from pptx import Presentation
from docx.oxml.shared import OxmlElement
from pptx.enum.chart import XL_CHART_TYPE
from pptx.chart.data import CategoryChartData
def set_chart_value_axis_no_fill(chart):
element = chart.element
valAx = element.valAx_lst[0]
node = OxmlElement('c:spPr')
node1 = OxmlElement('a:ln')
node2 = OxmlElement('a:noFill')
node1.append(node2)
node.append(node1)
valAx.append(node)
prs = Presentation()
slide = prs.slides.add_slide(prs.slide_layouts[5])
chart_data = CategoryChartData()
chart_data.categories = ['East', 'West', 'Midwest']
chart_data.add_series('Series 1', (19.2, 21.4, 16.7))
x, y, cx, cy = Inches(2), Inches(2), Inches(6), Inches(4.5)
chart = slide.shapes.add_chart(XL_CHART_TYPE.COLUMN_CLUSTERED, x, y, cx, cy, chart_data)
chart = chart.chart
set_chart_value_axis_no_fill(chart)
prs.save('test.pptx')
chart.value_axis.format.line.fill.background()
Should also do the trick.
I want to set the Value Axis of a chart to No line. But I can't find the related information from documents of python-pptx and PowerPoint VBA .
Here is my code.
I want it looks like this.
Looking forward to your reply. Best Wishes!