- 积分
- 237
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2018-10-24
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
python快速绘图,初处尝试,简单绘制图中图
- import numpy as np
- import matplotlib.pyplot as plt
- # =============================================================================
- # 创建数据
- # =============================================================================
- # =============================================================================
- # x = [1,2,3,4,5,6,7]
- # y = [1,3,4,2,5,8,6]
- # =============================================================================
- x = np.linspace(1,3,1000)
- # 绘制大图
- left,bottm,width,height = 0.1,0.1,0.8,0.8
- fig = plt.figure()
- ax1 = fig.add_axes([left,bottm,width,height])
- ax1.plot(x,x**2,'r')
- ax1.set_xlabel('x')
- ax1.set_ylabel('y')
- ax1.set_title('title')
- # 绘制图1
- left,bottm,width,height = 0.2,0.6,0.25,0.25
- plt.axes([left,bottm,width,height])
- plt.plot(x,np.exp(x**3),'b')
- plt.xlabel('x')
- plt.ylabel('y')
- plt.title('title inside1')
- # 绘制图2
- left,bottm,width,height = 0.6,0.2,0.25,0.25
- plt.axes([left,bottm,width,height])
- plt.plot(x,np.exp(-x),'g')
- plt.xlabel('x')
- plt.ylabel('y')
- plt.title('title inside2')
- # =============================================================================
- # plt.show()
- # =============================================================================
- plt.savefig('test3.png',dpi=520)
复制代码
|
-
评分
-
查看全部评分
|