如何设置openpyxl ScatterChart的线条颜色
How to set line color of openpyxl ScatterChart
我正在尝试将 openpyxl 散点图的线设置为绿色:
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
虽然此代码不会导致任何问题,但它不会更改默认的线条颜色。更改线条颜色的正确方法是什么?
有趣的是,我可以使用以下方法将样式设置为虚线或点线:
lineProp = drawing.line.LineProperties(prstDash='dash')
series.graphicalProperties.line = lineProp
事实证明,线宽可以保持默认。我通过将 solidFill
设置为 openpyxl.drawing.colors.ColorChoice
:
的实例来使颜色更改起作用
lineProp = drawing.line.LineProperties(solidFill = drawing.colors.ColorChoice(prstClr='green'))
我正在尝试将 openpyxl 散点图的线设置为绿色:
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
虽然此代码不会导致任何问题,但它不会更改默认的线条颜色。更改线条颜色的正确方法是什么?
有趣的是,我可以使用以下方法将样式设置为虚线或点线:
lineProp = drawing.line.LineProperties(prstDash='dash')
series.graphicalProperties.line = lineProp
事实证明,线宽可以保持默认。我通过将 solidFill
设置为 openpyxl.drawing.colors.ColorChoice
:
lineProp = drawing.line.LineProperties(solidFill = drawing.colors.ColorChoice(prstClr='green'))