我无法为反转图形填充颜色,也无法自定义y轴。有人可以帮我吗?

问题描述 投票:0回答:1

绘制图形时我面临以下困难:

1:无法为反转图形填充颜色。

2:如何自定义y轴值。从文档中找不到任何帮助。

enter image description here

python graph xlsxwriter
1个回答
0
投票

无法为反转图形填充颜色。

在XlsxWriter图表中,您可以使用invert_if_negative系列属性(see docs)。例如:

import xlsxwriter

workbook = xlsxwriter.Workbook('chart.xlsx')
worksheet = workbook.add_worksheet()

# Create a new Chart object.
chart = workbook.add_chart({'type': 'column'})

# Write some data to add to plot on the chart.

worksheet.write_column('A1', [1, 3, -2, 1, -1])

# Configure the chart.
chart.add_series({'values': '=Sheet1!$A$1:$A$5',
                  'invert_if_negative': True})

# Insert the chart into the worksheet.
worksheet.insert_chart('C2', chart)


workbook.close()

输出

enter image description here

我如何自定义y轴值。从文档中找不到任何帮助。

您可以自定义x和y轴值的几乎所有属性,或其他属性。请参阅文档herehere

© www.soinside.com 2019 - 2024. All rights reserved.