openpyxl: chart.title = "Chart Heading" 无效。如何将标题添加到散点图?

openpyxl: chart.title = "Chart Heading" not functional. How do I add the heading to a scatter chart?

我正在使用 Python 3.6.3 和 openpyxl 2.5.4

我写了一些代码,发现用 chart.title = "Test Heading" 设置我的图表标题没有任何作用。作为完整性检查,我复制了 运行 example from here:

from openpyxl import Workbook
from openpyxl.chart import (
    ScatterChart,
    Reference,
    Series,
)

wb = Workbook()
ws = wb.active

rows = [
    ['Size', 'Batch 1', 'Batch 2'],
    [2, 40, 30],
    [3, 40, 25],
    [4, 50, 30],
    [5, 30, 25],
    [6, 25, 35],
    [7, 20, 40],
]

for row in rows:
    ws.append(row)

chart = ScatterChart()
chart.title = "Scatter Chart"
chart.style = 13
chart.x_axis.title = 'Size'
chart.y_axis.title = 'Percentage'

xvalues = Reference(ws, min_col=1, min_row=2, max_row=7)
for i in range(2, 4):
    values = Reference(ws, min_col=i, min_row=1, max_row=7)
    series = Series(values, xvalues, title_from_data=True)
    chart.series.append(series)

ws.add_chart(chart, "A10")

wb.save("scatter.xlsx")

遗憾的是,我的示例输出中的标题仍然缺失:

奇怪的是,将 title_from_data=True 更改为 title_from_data=False 似乎对图表的内容也没有影响。

这看起来很像您用来查看文件的应用程序中的错误,我怀疑是 LibreOffice。