方法一:标准方法
主要是利用了位移函数matpltlib.transforms.ScaledTransformation(xtr,ytr,figure.dpi_scale_trans)。这个只是写明了
调整幅度。还要用原来的坐标系axes.transData与之相加,得到了最终的偏移坐标。
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib.transforms as transforms
% matplotlib inline
def setup(layout=None):#定义画布,设置图的数量
assert layout is not None
fig=plt.figure()
ax=fig.add_subplot(layout)
return fig,ax
def ordata():#生成数据
t=np.arange(0,2.5,0.01)
s=np.sin(5*np.pi*t)
return t,s
def plotone():#先画出原图
line=axes.plot(t,s,linewidth=5,color='r')
return line
def offset(fig,t,s,line,axes):#根据偏移的坐标画出新的图形
delta=2/72
offset=transforms.ScaledTranslation(delta,-delta,fig.dpi_scale_trans)
newoffset=