Python PPTX Как изменить формат линии в диаграмме на основе XL_CHART_TYPE.LINE - PullRequest
0 голосов
/ 05 июня 2018

Как получить доступ к объекту формата линии для ряда в диаграмме на основе XL_CHART_TYPE.LINE?

chart_data = ChartData()
vec2 = [ float(i.value) for i in xl_sheet.col(1)]
chart_data.categories = [ datetime.datetime.fromordinal(int(693594+i.value )) for i in xl_sheet.col(0)]
uu=chart_data.add_series('Model1',    tuple(vec2))

У меня нет доступа к формату линии ряда по

uu.format.line.color.rgb = RGBColor((100,100,100)) 

1 Ответ

0 голосов
/ 05 июня 2018

После создания диаграммы вы получаете доступ к каждой строке по серии, которую представляет эта строка:

graphic_frame = slide.shapes.add_chart(..chart_data,..)
# ---graphic frame is the shape containing the chart, not the chart itself---
chart = graphic_frame.chart
# ---get the desired series from the chart---
series = chart.series[0]
# ---series.format is a ChartFormat object, which in turn provides access to
#    the LineFormat object for that series---
line = series.format.line
# ---change the line style, color, etc. the same way as for any other line---
line.color.rgb = RGBColor(255, 0, 0)
...