python画曲线,画子图

画曲线

import matplotlib.pylab as pyl
import numpy as np
x = np.linspace(0.01, 3.5, 100, endpoint=True)
y = 1/x
x1=x
y1 = 2/x
x2=x
y2 = 3/x
fig = pyl.figure()
ax = fig.add_subplot(111)
ax.set_xlim(0,3.5) #设置图形的范围,默认为[0,1]
ax.set_ylim(0,3.5) #设置图形的范围,默认为[0,1]
ax.grid()  #添加网格
ax.set_aspect('equal')  #x轴和y轴等比例
pyl.plot(x,y)
pyl.plot(x1,y1)
pyl.plot(x2,y2)
pyl.xlabel('economics books')
pyl.ylabel('books about other subjects')
pyl.title('(d) indifferent curve')
pyl.annotate('increasing',xy=(2.5,2.5),xytext=(1.5,1.8),arrowprops=dict(arrowstyle="->",connectionstyle="arc3"))
pyl.show()

画子图

import matplotlib.pylab as pyl
import numpy as np

#fig = pyl.figure(22)
fig = pyl.figure(dpi=500,figsize=(3,3))
ax = fig.add_subplot(331)
x = [0,1]
y = [1,0]
x1 = [0,2]
y1 = [2,0]
x2 = [0,3]
y2 = [3,0]
ax.set_xlim(0,3.5) #设置图形的范围,默认为[0,1]
ax.set_ylim(0,3.5) #设置图形的范围,默认为[0,1]
ax.grid()  #添加网格
ax.set_aspect('equal')  #x轴和y轴等比例
pyl.plot(x,y)
pyl.plot(x1,y1)
pyl.plot(x2,y2)
pyl.xlabel('economics books')
pyl.ylabel('books about other subjects')
pyl.title('indifferent curve')
pyl.annotate('increasing',xy=(2,2),xytext=(1,1.3),arrowprops=dict(arrowstyle="->",connectionstyle="arc3"))

ax = fig.add_subplot(333)
x = [0,3.5]
y = [0,3.5]
x1 = [0,2.5]
y1 = [1,3.5]
x2 = [1,3.5]
y2 = [0,2.5]
ax.set_xlim(0,3.5) #设置图形的范围,默认为[0,1]
ax.set_ylim(0,3.5) #设置图形的范围,默认为[0,1]
ax.grid()  #添加网格
ax.set_aspect('equal')  #x轴和y轴等比例
pyl.plot(x,y)
pyl.plot(x1,y1)
pyl.plot(x2,y2)
pyl.xlabel('economics books')
pyl.ylabel('books about other subjects')
pyl.title('indifferent curve')
pyl.annotate('increasing',xy=(0.5,3),xytext=(1.5,1.6),arrowprops=dict(arrowstyle="->",connectionstyle="arc3"))

ax = fig.add_subplot(337)
x = [1,1]
y = [0,3.5]
x1 = [2,2]
y1 = [0,3.5]
x2 = [3,3]
y2 = [0,3.5]
ax.set_xlim(0,3.5) #设置图形的范围,默认为[0,1]
ax.set_ylim(0,3.5) #设置图形的范围,默认为[0,1]
ax.grid()  #添加网格
ax.set_aspect('equal')  #x轴和y轴等比例
pyl.plot(x,y)
pyl.plot(x1,y1)
pyl.plot(x2,y2)
pyl.xlabel('economics books')
pyl.ylabel('books about other subjects')
pyl.title('indifferent curve')
pyl.annotate('increasing',xy=(3.5,1.5),xytext=(1.5,1.44),arrowprops=dict(arrowstyle="->",connectionstyle="arc3"))

ax = fig.add_subplot(339)
x = np.linspace(0.01, 3.5, 100, endpoint=True)
y = 1/x
x1=x
y1 = 2/x
x2=x
y2 = 3/x
ax.set_xlim(0,3.5) #设置图形的范围,默认为[0,1]
ax.set_ylim(0,3.5) #设置图形的范围,默认为[0,1]
ax.grid()  #添加网格
ax.set_aspect('equal')  #x轴和y轴等比例
pyl.plot(x,y)
pyl.plot(x1,y1)
pyl.plot(x2,y2)
pyl.xlabel('economics books')
pyl.ylabel('books about other subjects')
pyl.title('indifferent curve')
pyl.annotate('increasing',xy=(2.5,2.5),xytext=(1.5,1.8),arrowprops=dict(arrowstyle="->",connectionstyle="arc3"))
pyl.show()
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小蜗笔记

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值