admin管理员组文章数量:1122846
I am trying to use openpyxl to automate the creation of graphs in excel. However, the charts that are being produced are not generating axes when I run the code on my machine.
I am using the example code for creating a scatter plot found here: .1/charts/scatter.html
My graph looks like this: scatter plot
My coworker ran the same code on their computer and it displayed correctly. Could it be an issue with the way Python is installed?
I am using Python 3.13.0 and version 3.1.5 of openpyxl although I have also tried version 3.1.2 based on an older question with no luck.
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")
本文标签: pythonx and y axis not displaying in chart created by openpyxlStack Overflow
版权声明:本文标题:python - x and y axis not displaying in chart created by openpyxl - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736306440a1932959.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论