小编roc*_*996的帖子

使用 Python 为正值和负值绘制不同颜色的直方图

我使用 Python 绘制了以下图:

import matplotlib.pyplot as plt
plt.hist([x*100 for x in relativeError], bins = 100)
plt.xlabel("Relative Error [%]")
plt.ylabel("#samples")
plt.axvline(x=0, linestyle='--',linewidth=1, color='grey')
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

但我真正想要的是根据值是正值还是负值来拥有不同的颜色。

python matplotlib python-3.x

2
推荐指数
1
解决办法
3947
查看次数

标签 统计

matplotlib ×1

python ×1

python-3.x ×1