python绘图作品_【python】绘图集锦

1 defdouble_Y_axis():2 #sns.set_style("darkgrid")

3

4 without_rain = pd.read_csv("./data/s1201/S1201_2015_5_26.csv")5 with_rain = pd.read_csv("./data/s1201/S1201_2016_5_25.csv")6

7 y1_1= without_rain['TEMP']8 y1_2 = without_rain['PRECIPITATIONAMOUNT']9 x1 = without_rain['OBSTIME']10

11 y2_1 = with_rain['TEMP']12 y2_2 = with_rain['PRECIPITATIONAMOUNT']13 x2 = with_rain['OBSTIME']14

15 day_1 = [parser(x) for x inx1]16 day_2 = [parser(x) for x inx2]17

18

19 fig =plt.figure()20 ax1_1 = fig.add_subplot(211)21 ax2_1 = fig.add_subplot(212)22

23 ax1_2 =ax1_1.twinx()24 ax2_2 =ax2_1.twinx()25

26 ax1_1.plot(day_1 ,y1_1, 'b',marker='o',label='temp')27 ax1_2.plot(day_1,y1_2,'r',marker='o',label='precipitation')28

29 ax2_1.plot(day_2 ,y2_1, 'b',marker='o',label= 'temp')30 ax2_2.plot(day_2,y2_2,'r',marker='o',label = 'precipitation')31

32 hours = mdates.DateFormatter('%H:%M')33

34 ax1_1.set_title("The temp variation without rain")35 ax1_1.set_ylabel('Y values for temp')36 ax1_2.set_ylabel('Y values for precipitation')37 ax1_2.set_ylim(-0.2,0.2,0.1)38 ax1_1.set_ylim(15,30)39

40 ax2_1.set_title("The temp variation with rain")41 ax2_1.set_ylabel('Y values for temp')42 ax2_2.set_ylabel('Y values for precipitation')43 ax1_1.xaxis.set_major_formatter(hours)44 ax2_1.xaxis.set_major_formatter(hours)45 ax1_1.grid(color = '#95a5a6')46 ax2_1.grid(color = '#95a5a6')47

48 ax1_1.legend()49 ax1_2.legend()50

51 plt.show()

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值