15分钟
混合坐标系
- 有时候你需要混合
data
坐标系和Axes
坐标系。通过matplotlib.transforms.blended_transform_factory(ax.transData, ax.transAxes)
能够返回一个混合坐标系,该坐标系中:x
坐标为data
坐标系,y
坐标为Axes
坐标系。因此该坐标系中(1,1)
表示的是data
坐标系中x=1
但是y
位于最上方的点。
2. 有两个函数返回特定的混合坐标系:
matplotlib.axes.Axes.get_xaxis_transform()
:等价于matplotlib.transforms.blended_transform_factory(ax.transData, ax.transAxes)
。x
坐标为data
坐标系,y
坐标为Axes
坐标系。常用于绘制x
轴的label
、tick
、gridline
。matplotlib.axes.Axes.get_yaxis_transform().
:等价于matplotlib.transforms.blended_transform_factory(ax.transAxes,ax.transData)
。x
坐标为Axes
坐标系,y
坐标为data
坐标系。常用于绘制y
轴的label
、tick
、gridline
。
学员评价