Python 如何使用openpyxl设置图表区的图形属性
我想更改图表区域的背景色,并删除所有边框。关于背景色,我尝试了建议的解决方案:但该解决方案不适用于任何图表,如条形图、面积图、折线图、散点图、雷达艺术等。。。我尝试了两个openpyxl版本:2.4.7、2.4.9。没有成功Python 如何使用openpyxl设置图表区的图形属性,python,python-3.x,charts,openpyxl,Python,Python 3.x,Charts,Openpyxl,我想更改图表区域的背景色,并删除所有边框。关于背景色,我尝试了建议的解决方案:但该解决方案不适用于任何图表,如条形图、面积图、折线图、散点图、雷达艺术等。。。我尝试了两个openpyxl版本:2.4.7、2.4.9。没有成功 # setup the chart chart = LineChart() # test to remove border line ***************************************************** chart.graphical
# setup the chart
chart = LineChart()
# test to remove border line
*****************************************************
chart.graphical_properties =
GraphicalProperties(ln=LineProperties(noFill=True))
chart.height = 9
chart.width = 13.4
props = GraphicalProperties(solidFill="f2f2f2")
# setup and append the first series
list_names = ['Fund', 'Market', 'Benchmark']
data = Reference(ws2, min_col=2, min_row=1, max_col=n + 1, max_row=p +
1)
chart.x_axis.number_format = 'mmm yy'
chart.x_axis.majorTimeUnit = "months"
chart.add_data(data, titles_from_data=True)
dates = Reference(ws2, min_col=1, min_row=2, max_col=1, max_row=1 + p)
chart.set_categories(dates)
# Style the lines
chart.series[0].graphicalProperties.line.solidFill = "7E3F00"
chart.series[1].graphicalProperties.line.solidFill = "45788C"
chart.series[2].graphicalProperties.line.solidFill = "8BADD9"
chart.plot_area.graphicalProperties = props
# test to change background color
*****************************************************
chart.graphical_properties = props
ws1.add_chart(chart, "B14")
我还试图删除图表区域的边界。我找到了这个帖子:。但我不明白如何修改库。我有点惊讶,没有比这更简单的方法了
非常感谢你的帮助 这个过程可能有助于找到答案
这很困难,因为底层XML是7、8、9层的:-(openpyxl尽可能地简化它,并且不公开所有内容,但是更改可以在邮件列表上讨论。嗨,Charlie,谢谢你的回复。你能给我一些指导吗?