爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 11316|回复: 2

[讨论] python快速绘图(图中图绘制)

[复制链接]

新浪微博达人勋

发表于 2020-2-3 21:45:20 | 显示全部楼层 |阅读模式

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

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

x
python快速绘图,初处尝试,简单绘制图中图
  1. import numpy as np
  2. import matplotlib.pyplot as plt
  3. # =============================================================================
  4. # 创建数据
  5. # =============================================================================
  6. # =============================================================================
  7. # x = [1,2,3,4,5,6,7]
  8. # y = [1,3,4,2,5,8,6]
  9. # =============================================================================
  10. x = np.linspace(1,3,1000)
  11. # 绘制大图
  12. left,bottm,width,height = 0.1,0.1,0.8,0.8
  13. fig = plt.figure()
  14. ax1 = fig.add_axes([left,bottm,width,height])
  15. ax1.plot(x,x**2,'r')
  16. ax1.set_xlabel('x')
  17. ax1.set_ylabel('y')
  18. ax1.set_title('title')

  19. # 绘制图1
  20. left,bottm,width,height = 0.2,0.6,0.25,0.25
  21. plt.axes([left,bottm,width,height])
  22. plt.plot(x,np.exp(x**3),'b')
  23. plt.xlabel('x')
  24. plt.ylabel('y')
  25. plt.title('title inside1')

  26. # 绘制图2
  27. left,bottm,width,height = 0.6,0.2,0.25,0.25
  28. plt.axes([left,bottm,width,height])
  29. plt.plot(x,np.exp(-x),'g')
  30. plt.xlabel('x')
  31. plt.ylabel('y')
  32. plt.title('title inside2')
  33. # =============================================================================
  34. # plt.show()
  35. # =============================================================================
  36. plt.savefig('test3.png',dpi=520)
复制代码


test3.png

评分

参与人数 1金钱 +10 收起 理由
眼里有星辰 + 10 很给力!

查看全部评分

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

新浪微博达人勋

发表于 2020-2-17 08:27:29 | 显示全部楼层
厉害!学习学习
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

新浪微博达人勋

发表于 2022-4-6 22:46:56 | 显示全部楼层
MATLAB用axis也一样
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

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

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

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