欢迎转载,转载请保留以下微信公众号二维码,感谢大家支持
今天我们要做的图如下格式:
平时时间太少,不说废话,直接给大家发布Python代码了:
import numpy as np
import matplotlib.pyplot as plt
up_num = (-210, -300, -450, -175, -287)
down_num = (295, 320, 450, 106, 65)
fig, ax = plt.subplots()
ind = np.arange(len(up_num)) # the x locations for the groups
width = 0.35 # the width of the bars
rects1 = ax.bar(ind, up_num, width, color='green', label='up_num')
rects2 = ax.bar(ind, down_num, width, color='red', label='down_num')
# Add some text for labels, title and custom x-axis tick labels, etc.
ax.set_ylabel('Gene number')
ax.set_title('The DEGs')
ax.set_xticks(ind)
ax.set_xticklabels(('Treatmen_1', 'Treatmen_2', 'Treatmen_3', 'Treatmen_4', 'Treatmen_5'))
ax.legend(loc = 'best')
ax.spines['right'].set_color('none')
ax.spines['top'].set_color('none')
ax.set_ylim(-600,600)
#ax.spines['bottom'].set_position(('data', 0))
#ax.spines['left'].set_position(('data', 0))
plt.show()
plt.savefig('C:/Users/Administrator/Desktop/result.pdf')
领取专属 10元无门槛券
私享最新 技术干货