Matplotlib-transforms

提供:Dev Guides
移動先:案内検索

Matplotlib-変換

matplotlibパッケージは、座標系間を簡単に移動できるように、変換フレームワークの上に構築されています。 4つの座標系を使用できます。 システムは、以下の表に簡単に説明されています-

Coordinate Transformation Object Description
Data ax.transData The user land data coordinate system. controlled by the xlim and ylim
Axes ax.transAxes The coordinate system of the Axes. (0,0) is bottom left and (1,1) is top right of the axes.
Figure fig.transFigure The coordinate system of the Figure. (0,0) is bottom left and (1,1) is top right of the figure
display None

This is the pixel coordinate system of the display. (0,0) is the bottom left and (width, height) is the top right of display in pixels.

あるいは、(matplotlib.transforms.IdentityTransform())をNoneの代わりに使用することもできます。

次の例を考慮してください-

axes.text(x,y,"my label")

テキストは、データポイント(x、y)の理論上の位置に配置されます。 したがって、「データの調整」について話します。

他の変換オブジェクトを使用して、配置を制御できます。 たとえば、上記のテストを軸座標系の中心に配置する場合は、次のコード行を実行します-

axes.text(0.5, 0.5, "middle of graph", transform=axes.transAxes)

これらの変換は、あらゆる種類のMatplotlibオブジェクトに使用できます。 ax.text のデフォルトの変換は ax.transData であり、 fig.text のデフォルトの変換は* fig.transFigure。*です。

Axes座標系は、Axesにテキストを配置するときに非常に便利です。 多くの場合、固定位置にテキストバブルが必要になることがあります。たとえば、Axesペインの左上で、パンまたはズームするときにその位置を固定したままにします。