如何在openpyxl的散点图中使用字符串作为yaxis值?

2024-06-28 19:22:28 发布

您现在位置:Python中文网/ 问答频道 /正文

似乎目前在y轴上只支持整数作为值。我不能使用条形图,因为它不接受序列中的xvalues。在

    # the columns value here is int
    values = Reference(ws, (2, 2), (10, 2))
    # the columns value here is string
    values2 = Reference(ws, (2, 1), (10, 1))
    series = Series(values, xvalues=values2, title="Chart")
    chart = ScatterChart()
    chart.append(series)
    ws.add_chart(chart)
    wb.save(file_name) # exception

File "/lib/python3.4/site-packages/openpyxl/charts/graph.py", line 31, in compute_axes
    mini, maxi = self._get_extremes('xvalues')
File "/lib/python3.4/site-packages/openpyxl/charts/graph.py", line 58, in _get_extremes
    return min(series_min), max(series_max)
TypeError: unorderable types: NoneType() < int()

Tags: columnsthewshereisvaluelibchart
1条回答
网友
1楼 · 发布于 2024-06-28 19:22:28

如果没有样本数据,很难说太多,但有一点需要注意,数据序列既有数据集,也有标签。散点图不能真正与非数值轴一起工作。在

在项目的示例代码中有一个带有标签的条形图示例。在

相关问题 更多 >