1
python-pptx是否有可能在不同於其他條形圖中的特定條形上色?我的意圖是根據數值對欄進行着色。默認情況下,全部爲藍色,但如果該值低於某個閾值,則該欄會顯示爲紅色。不同於Python的顏色特定條形圖PPTX
下面是我用所有的酒吧當前代碼藍色十歲上下,RGB(65105225)
# HUMIDITY CHART
chart_data = ChartData()
chart_data.categories = list(m.columns)
chart_data.add_series('Humidity', list(m.loc[svc,'Humidity']), 3)
graphic_frame = s.placeholders[14].insert_chart(XL_CHART_TYPE.COLUMN_CLUSTERED, chart_data)
chart = graphic_frame.chart
plot = chart.plots[0]
plot.has_data_labels = True
plot.overlap = 0
plot.gap_width = 30
data_labels = plot.data_labels
data_labels.font.size = Pt(11)
data_labels.font.color.rgb = RGBColor(0,0,0)
data_labels.number_format = "#,##0"
chart.series[0].fill.solid()
chart.series[0].fill.fore_color.rgb = RGBColor(65,105,225)
謝謝,但我接受任何AttributeError的:「檢測BarSeries」對象有沒有屬性「點」,或AttributeError錯誤:「的SeriesCollection」對象在我的各種沒有屬性「點」嘗試。 – idazuwaika
嘗試了兩個點= chart.series.points [bar_idx]和point = chart.series [0] .points [bar_idx] – idazuwaika
您使用的是什麼版本的'python-pptx'?聽起來像是升級的時候了。 BarSeries應該有'.points'屬性。 – scanny