爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 3891|回复: 1

MeteoInfoLab脚本示例:多Y轴图

[复制链接]

新浪微博达人勋

发表于 2015-6-19 09:11:48 | 显示全部楼层 |阅读模式

登录后查看更多精彩内容~

您需要 登录 才可以下载或查看,没有帐号?立即注册 新浪微博登陆

x
本帖最后由 MeteoInfo 于 2016-5-25 18:08 编辑

数据范围相差比较大的数据序列进行对比的时候多Y轴图就很重要了。MeteoInfoLab中提供了一个twinx函数来根据已有的坐标系(Axes)生成一个新的Axes,这个命令会使得已有的Axes不绘制右边的Y轴,而新生成的Axes只绘制右边的Y轴。yaxis函数可以对某个Axes的Y轴进行相应的设置,第一个参数是某个Axes的对象,可以设置Y轴的颜色(color)和偏移(shift),对于超过2个Y轴的图形来说第3个Y轴就必须设置偏移以避免压盖。

双Y轴图:
Image00834.png


多Y轴图:
Image00835.png


脚本程序:
  1. ax1 = axes()
  2. yaxis(ax1, color='b')
  3. t = arange(0.01, 10.0, 0.01)
  4. s1 = exp(t)
  5. plot(t, s1, 'b-', linewidth=2)
  6. xlabel('time (s)')
  7. ylabel('exp', color='b')

  8. ax2 = twinx(ax1)
  9. yaxis(ax2, color='r')
  10. s2 = sin(2*pi*t)
  11. plot(t, s2, 'r.')
  12. ylabel('sin', color='r')
  13. show()



  1. ax1 = axes(position=[0.113,0.15,0.7,0.8])
  2. yaxis(ax1, color='b')
  3. line1 = plot([0, 1, 2], [0, 1, 2], 'b-', label="Density")
  4. xlabel('Distance')
  5. ylabel('Density', color='b')
  6. title('Mutiple Y Axis Sample')

  7. ax2 = twinx(ax1)
  8. yaxis(ax2, color='r')
  9. line2 = plot([0, 1, 2], [0, 3, 2], 'r-', label="Temperature")
  10. ylabel('Temperature', color='r')

  11. ax3 = twinx(ax1)
  12. yaxis(ax3, shift=60, color='g')
  13. line3 = plot([0, 1, 2], [50, 30, 15], 'g-', label="Velocity")
  14. ylabel('Velocity', color='g')
  15. lines = [line1, line2, line3]
  16. legend(lines)
  17. show()








密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2016-6-26 20:25:27 | 显示全部楼层
强大的 MeteoInfoLab
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

Copyright ©2011-2014 bbs.06climate.com All Rights Reserved.  Powered by Discuz! (京ICP-10201084)

本站信息均由会员发表,不代表气象家园立场,禁止在本站发表与国家法律相抵触言论

快速回复 返回顶部 返回列表