使用Python openpyxl,如何更改图表图例中的字体大小?
使用Python openpyxl,如何更改图表图例中的字体大小使用Python openpyxl,如何更改图表图例中的字体大小?,python,python-3.x,openpyxl,Python,Python 3.x,Openpyxl,使用Python openpyxl,如何更改图表图例中的字体大小 #Create Chart chart1 = BarChart() chart1.type = "col" chart1.style = 10 chart1.title = "Rolling 4 weeeeks" chart1.legend.position = 'b' chart1.legend.font = FONT(name = 'Calibri', size = 9) 我的图表图例文本的大小仍然是10 谢谢 对于Lege
#Create Chart
chart1 = BarChart()
chart1.type = "col"
chart1.style = 10
chart1.title = "Rolling 4 weeeeks"
chart1.legend.position = 'b'
chart1.legend.font = FONT(name = 'Calibri', size = 9)
我的图表图例文本的大小仍然是10
谢谢 对于
Legend()
,没有.font
属性
用于Legend()
的说明如下:
txPr(别名:textProperties)
(灵感来自)
Values must be of type <class ‘openpyxl.chart.text.RichText’>
from openpyxl.chart.text import RichText
from openpyxl.drawing.text import Paragraph, ParagraphProperties, CharacterProperties, Font
font = Font(typeface='Verdana')
size = 2000 # 20 point size
cp = CharacterProperties(latin=font, sz=size, b=True) # Try bold text
pp = ParagraphProperties(defRPr=cp)
rtp = RichText(p=[Paragraph(pPr=pp, endParaRPr=cp)])
ch1.legend.textProperties = rtp