如何在 Matplotlib 中绘制没有线和点的误差条图? [英] How can I draw an errorbar graph without lines and points in Matplotlib?
本文介绍了如何在 Matplotlib 中绘制没有线和点的误差条图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我目前正在使用以下代码绘制误差条图.
plt.errorbar(log_I_mean_,log_V2_mean_,xerr,yerr,'.')
但是,最终结果在每个误差线交点的中心都显示了一个圆点.像科学工作中那样,如何只绘制没有中心点的误差线?
解决方案
使用'none'
代替'.'
:
将matplotlib.pyplot导入为pltx = np.arange(0.1,4,0.5)y = np.exp(-x)yerr = 0.1 + 0.2*np.sqrt(x)xerr = 0.1 + yerrplt.figure()plt.errorbar(x, y, 0.2, 0.4,'无')plt.title("最简单的误差条,x 为 0.2,y 为 0.4")
结果:
附言这是 pylab 此处>
I am currently using the following code to plot errorbar graphs.
plt.errorbar(log_I_mean_, log_V2_mean_, xerr, yerr, '.')
However, the end result shows a circular point in the center of each errorbar intersection point. How can I plot just the errorbars without the central point, as is required in scientific work?
解决方案
use 'none'
instead of '.'
:
import matplotlib.pyplot as plt
x = np.arange(0.1, 4, 0.5)
y = np.exp(-x)
yerr = 0.1 + 0.2*np.sqrt(x)
xerr = 0.1 + yerr
plt.figure()
plt.errorbar(x, y, 0.2, 0.4,'none')
plt.title("Simplest errorbars, 0.2 in x, 0.4 in y")
result:
P.S. this is slightly modified version of part of the example of pylab here
这篇关于如何在 Matplotlib 中绘制没有线和点的误差条图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文