3. 混合坐标系

  1. 有时候你需要混合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轴的labeltickgridline
    • matplotlib.axes.Axes.get_yaxis_transform().:等价于 matplotlib.transforms.blended_transform_factory(ax.transAxes,ax.transData)x坐标为Axes坐标系,y坐标为data坐标系。常用于绘制y轴的labeltickgridline