How to set line color of openpyxl ScatterChart

元气小坏坏 提交于 2020-04-11 07:47:52

问题


I am trying to set the line of an openpyxl scatter chart to green:

from openpyxl import *

book = workbook.Workbook()
ws = book.active
xRef = chart.Reference(ws, min_col=1, min_row=2, max_row=22)
yRef = chart.Reference(ws, min_col=2, min_row=2, max_row=22)
chart.Series(yRef, xvalues=xRef, title='test')
lineProp = drawing.line.LineProperties(solidFill = 'green')
series.graphicalProperties.line = lineProp    

While this code does not cause any problems, it does not change the line color from the default. What is the correct way to change the line color?

Interestingly I have no problem setting the style to dashed or dotted using:

lineProp = drawing.line.LineProperties(prstDash='dash')
series.graphicalProperties.line = lineProp

回答1:


As it turns out, the line width can remain default. I got the color change to work by setting solidFill to an instance of openpyxl.drawing.colors.ColorChoice:

lineProp = drawing.line.LineProperties(solidFill = drawing.colors.ColorChoice(prstClr='green'))


来源:https://stackoverflow.com/questions/34500606/how-to-set-line-color-of-openpyxl-scatterchart

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!