python绘制高清、有颜值的科研图

欢迎转载,转载请保留以下微信公众号二维码,感谢大家支持

今天我们要做的图如下格式:

平时时间太少,不说废话,直接给大家发布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')

  • 发表于:
  • 原文链接https://kuaibao.qq.com/s/20180711G008N600?refer=cp_1026
  • 腾讯「腾讯云开发者社区」是腾讯内容开放平台帐号(企鹅号)传播渠道之一,根据《腾讯内容开放平台服务协议》转载发布内容。
  • 如有侵权,请联系 cloudcommunity@tencent.com 删除。

同媒体快讯

扫码关注腾讯云开发者

领取腾讯云代金券