Python 如何在matplotlib模块中更改我的错误条格式
我正试图找出如何在我的绘图中只生成带有cap“-”的上部错误条,我已经通过Python 如何在matplotlib模块中更改我的错误条格式,python,matplotlib,errorbar,Python,Matplotlib,Errorbar,我正试图找出如何在我的绘图中只生成带有cap“-”的上部错误条,我已经通过lolims参数得出了这个结论。不幸的是,我的错误栏用箭头标记,我更喜欢默认的。上面的子图是我想要的错误条,下面的子图是我想要在上面的子图上做的标记 我的代码: import pandas as pd import matplotlib.pyplot as plt sheet = pd.read_excel(load file with my data) fig, axs = plt.subplots(2, 1) fi
lolims
参数得出了这个结论。不幸的是,我的错误栏用箭头标记,我更喜欢默认的。上面的子图是我想要的错误条,下面的子图是我想要在上面的子图上做的标记
我的代码:
import pandas as pd
import matplotlib.pyplot as plt
sheet = pd.read_excel(load file with my data)
fig, axs = plt.subplots(2, 1)
fig.suptitle('Gene expression', fontsize=16)
axs[0].bar(sheet.columns, sheet.iloc[17],hatch="/", color="white", edgecolor="black")
axs[0].errorbar(sheet.columns, sheet.iloc[17], yerr=sheet.iloc[22], capsize=3, ecolor='black', fmt=' ', elinewidth=1,
lolims=True)
axs[1].bar(sheet.columns, sheet.iloc[17],hatch="-", color="white", edgecolor="black")
axs[1].errorbar(sheet.columns, sheet.iloc[17], yerr=sheet.iloc[22], capsize=3, ecolor='black', fmt=' ', elinewidth=1,)
plt.show()
和我的情节图:
如何实现它?根据您是否希望看到较低的大写字母,您有三种可能性:
这是否回答了您的问题?^这显示了如何从箭头改为大写字母。似乎根据可能的重复,将箭头改为大写字母是第三种可能性,还是我遗漏了什么?@BigBen:是的,确实如此-在这种情况下,你可以完全控制大写字母,所以如果你喜欢,甚至可以为不同的列设置不同的大写字母。
import matplotlib.pyplot as plt
fig,ax = plt.subplots(3)
x = range(1,4)
ax[0].bar(x, x, fc='w', ec='k')
ax[0].errorbar(x, x, yerr=[[0,0,0], [.1,.2,.3]], fmt='none', capsize=3)
ax[1].bar(x, x, fc='w', ec='k', zorder=1 )
ax[1].errorbar(x, x, yerr=[.1,.2,.3], fmt='none', capsize=3, zorder=0)
ax[2].bar(x, x, fc='w', ec='k')
_, cl, _ = ax[2].errorbar(x, x, yerr=[.1,.2,.3], lolims=True, fmt='none', capsize=3)
cl[0].set_marker('_')
#cl[1].set_marker('') # to remove the lower cap