Python - 绘制具有不均匀误差(高和低)的误差条形图

标签 python matplotlib errorbar

<分区>

我是 Stack Overflow 的新手,如果这是一个重复的问题或含糊不清,我深表歉意 - 我也是 Python 和一般编码的新手。

我想创建一个错误条形图,它在高和低上具有不相等的“错误限制”。

我将绘制一个月的平均温度,上误差需要是当月的最高温度,下误差需要是当月的最低温度。

我知道如何使用错误相等的错误栏,但不明白如何使它们不相等。

已添加图片以供引用。我将用来绘制图表的列表的一个简短示例是:

temps_avg = [46, 49, 58, 69, 73, 79, 84]
temps_high = [78, 80, 82, 88, 88, 93, 101]
temps_low = [21, 29, 25, 48, 54, 62, 70]

我想复制条形图,但没有误差线

Bar Chart I'd Like to Duplicate but without Even Error Bars

最佳答案

您可以在 matplotlib 的条形图的 yerr arg 中的一个元组中放置低和高误差限制:

import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.bar([0,1,2,3,4,5,6], temps_avg, yerr = (temps_low,temps_high))

关于Python - 绘制具有不均匀误差(高和低)的误差条形图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53138250/

相关文章:

r - ggplot2 - 用点躲避水平误差线

python - Django channel 不会使用 CHANNEL_LAYERS 启动 redis 服务器

python - 从 pie matplotlib 饼图中获取图例中的百分比

matplotlib - 误差条图透明度重叠

python - 将 matplotlib 子图图形保存到图像文件

python - %matplotlib inline 在 iPython 和 Jupyter 控制台上不起作用

javascript - 在 Dygraphs 中组合 scatter 和 customBars

python - 从 Mongoengine 中的列表字段中删除嵌入文档

python - 类似 Xpath 的嵌套 python 字典查询

python - Django/South 在 python manage.py schemamigration testapp --initial 上设置失败