我正在寻找一种使用Python包openpyxl
的方法来更改我的水平轴(x轴)在Excel图表上沿着y轴的位置.目前,我的所有数据都是负的,因此轴显示在图表区域的顶部.我想将水平轴与Y轴交叉的位置更改为-9999的值,以迫使其位于图表区域的底部.谢谢!
Sample code:
import random
import openpyxl
from openpyxl.chart import ScatterChart, Reference, Series
wb = openpyxl.Workbook()
ws = wb.active
for r,val in enumerate([1,2,3,4,5,6,7,8,9,10]):
ws.cell(row=r+1, column=1, value=val)
ws.cell(row=r+1, column=2, value=-1*random.random()*val)
chart1 = ScatterChart()
xvalues1 = Reference(ws, min_col=1, min_row=1, max_row=10)
yvalues1 = Reference(ws, min_col=2, min_row=1, max_row=10)
series1 = Series(values = yvalues1, xvalues = xvalues1)
chart1.series.append(series1)
ws.add_chart(chart1, "B11")
wb.save('test.xlsx')
Graph showing current behavior:
Settings I'd like to change with openpyxl:
Intended appearance of X-axis with chart: