import matplotlib.pyplot as plt
from matplotlib.transforms import blended_transform_factory
import numpy as np
x = np.linspace(0, 100,1000)
y = 100*np.sin(x)
text = 'Annotation'
f, ax = plt.subplots()
ax.plot(x,y)
trans = blended_transform_factory(x_transform=ax.transAxes, y_transform=ax.transData)
ax.annotate(text, xy=[0.5, 50], xycoords=trans,ha='center')
使用
blended_transform_factory(x_transform,y_transform)
。函数返回一个新的变换,该变换对x轴应用x_transform
,对y轴应用y_transform
。例如:然后将注释放在x轴的中心,y轴的
y=50
位置相关问题 更多 >
编程相关推荐