首页 > 解决方案 > ConversionError:无法将值转换为轴单位:Python matplotlib

问题描述

我想格式化 y 轴上的数字,使它们看起来像美元金额?例如 200 美元而不是 200 美元。

ticks = graph.get_yticks()

labels=['${}'.format(int(amt)) for amt in ticks]

graph.set_yticks(labels)

低于错误。在此先感谢。

ConversionError: Failed to convert value(s) to axis units: ['$125', '$150', '$175', '$200', '$225', '$250', '$275', '$300', '$325']

在此处输入图像描述

标签: pythonmatplotlib

解决方案


推荐阅读