python - 如何将条形图的下限误差限制为 0?
问题描述
我计算了 rttMeans 和 rttStds 数组。但是,rttStds 的值使得下限误差小于 0。
rttStds = [3.330311915835426, 3.3189677330174883, 3.3319538853150386, 3.325173772304221, 3.3374145232695813]
如何将较低的错误设置为 0 而不是 -#?
python条形图代码如下。
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
sns.set(rc={'figure.figsize':(18,16)},style='ticks',font_scale = 1.5,font='serif')
N = 5
ind = ['RSU1', 'RSU2', 'RSU3', 'RSU4', 'RSU5'] # the x locations for the groups
width = 0.4 # the width of the bars: can also be len(x) sequence
fig = plt.figure(figsize=(10,6))
ax = fig.add_subplot(111)
p1 = plt.bar(ind, rttMeans, width, yerr=rttStds, log=False, capsize = 16, color='green', hatch="/", error_kw=dict(elinewidth=3,ecolor='black'))
plt.margins(0.01, 0)
#Optional code - Make plot look nicer
plt.xticks(rotation=0)
i=0.18
for row in rttMeans:
plt.text(i, row, "{0:.1f}".format(row), color='black', ha="center")
i = i + 1
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)
params = {'axes.titlesize':24,
'axes.labelsize':24,
'xtick.labelsize':28,
'ytick.labelsize':28,
'legend.fontsize': 24,
'axes.spines.right':False,
'axes.spines.top':False}
plt.rcParams.update(params)
plt.tick_params(axis="y", labelsize=28, labelrotation=20, labelcolor="black")
plt.tick_params(axis="x", labelsize=28, labelrotation=20, labelcolor="black")
plt.ylabel('RT Time (millisecond)', fontsize=24)
plt.title('# Participating RSUs', fontsize=24)
# plt.savefig('RSUs.pdf', bbox_inches='tight')
plt.show()
解决方案
推荐阅读
- php - 在 PHP 的 for 循环中调用的存储 oracle 过程仅适用于最后一次迭代
- sql-server - MS SQL 2012 镜像数据库 - SID 不匹配导致故障转移时连接失败
- ios - APNS 证书的“撤销”和“下载”按钮被禁用
- module - 为什么我的新 Odoo 模块没有出现在模块列表中?
- google-chrome-extension - 如何自动化从 chrome 扩展到边缘的移植过程?
- c++ - Valgrind 和 QEMU - 无法检测到内存泄漏
- c++ - C++ 发布程序无法在 Visual Studio 2015 中加载图像和字体
- laravel - Laravel / Lumen $users = \App\User::find$Uid)->get();
- python - 如何将 pd 列或系列作为变量传递到 plt.plot
- java - 休眠@Embedded 和@Embeddable