我想能够把我的错误条颜色与条颜色相同。但是,基于我下面的代码,这种情况不会发生。在
# Plot
x = sig['Glycan Name_Seal']
y_seal = sig['Average RFU_Seal']
yerr_seal = sig['StDev_Seal']
y_human = sig['Average RFU_Human']
yerr_human = sig['StDev_Human']
barwidth=0.5
alpha=1
plt.figure(0, figsize=(18,6))
plt.bar(left=sig.index,
color=['blue', 'blue'], height=y_seal, width=barwidth, yerr=yerr_seal, label='Seal', alpha=alpha)
plt.bar(left=sig.index + barwidth,
color=['red', 'red'], height=y_human, width=barwidth, yerr=yerr_human, label='Human', alpha=alpha)
plt.ylim(0,2500)
plt.ylabel('Average RFU', fontsize=14)
plt.xlabel('Glycan Number', fontsize=14)
plt.xlim(0, 56)
plt.title('Pre-Complexed p-value < 0.01', fontsize=18)
plt.legend(fontsize=16)
# Add a vertical line to distinguish alpha(2,3) and alpha(2,6)
plt.plot([1, 1], [0, 2500], color="black", linewidth=2)
plt.plot([9, 9], [0, 2500], color="black", linewidth=2)
plt.plot([11, 11], [0, 2500], color="black", linewidth=2)
# Add the texts greek alpha(2,3) and alpha(2,6)
plt.annotate(r"$\alpha$(2,6)", (3.5, 2250), fontsize=14)
plt.annotate(r"$\alpha$(2,3)", (29, 2250), fontsize=14)
plt.annotate("asialoglycan", xy=(0.25, 1950), xytext=(2, 1950), arrowprops=dict(arrowstyle="->", linewidth=2), fontsize=14)
plt.annotate(r"$\alpha$(2,3) and $\alpha$(2,6)", xy=(10, 1850), xytext=(12, 1850), arrowprops=dict(arrowstyle="->", linewidth=2), fontsize=14)
plt.savefig('Average RFU Plot.pdf')
结果是Seal
数据显示为蓝色条和蓝色错误条,而{
是否可以使Human
数据显示为红色错误条?在
尝试在有问题的绘图中设置
ecolor='red'
。我建议在您的第一个绘图中也设置ecolor='blue'
,因为它看起来就像是蓝色的错误条,因为这是它们循环使用的第一种颜色。有关详细信息,请参见the documentation for plt.bar。在这在调用
plt.bar
中完成,如下所示:相关问题 更多 >
编程相关推荐