原视频链接:https://www.bilibili.com/video/av16378354/?p=17
import numpy as np
import matplotlib
matplotlib.use(“TkAgg”)
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.gridspec as gridspec
x=np.arange(1,8)
y=np.arange(2,9)
fig=plt.figure()
left,bottom,width,height=0.1,0.1,0.8,0.8 #图的位置和大小
ax1=fig.add_axes([left,bottom,width,height])
ax1.plot(x,y,“r”)
ax1.set_xlabel(“x”)
ax1.set_ylabel(“y”)
ax1.set_title(“title”)
left,bottom,width,height=0.2,0.6,0.25,0.25#图的位置和大小
ax2=fig.add_axes([left,bottom,width,height])
ax2.plot(y,x,“b”)
ax2.set_xlabel(“x”)
ax2.set_ylabel(“y”)
ax2.set_title(“title inside 1”)
plt.axes([0.6,0.2,0.25,0.25]) #图的位置和大小
plt.plot(y[::-1],x,“g”)
plt.xlabel(“x”)
plt.ylabel(“y”)
plt.title(“title inside 2”) #默认在当前图像内画图
plt.show()