Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Python openpyxl,如何更改图表图例中的字体大小?_Python_Python 3.x_Openpyxl - Fatal编程技术网

使用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

使用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


谢谢

对于
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