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
Advertisement
Answer
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'))