English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Matplotlib is built on top of the transformation framework, allowing easy movement between coordinate systems. Four coordinate systems can be used. These systems are briefly described in the table below -
Coordinate | Transformation object | Description |
Data | ax.transData | User land data coordinate system, controlled by xlim and ylim |
Axes | ax.transAxes | The coordinate system of the axis. (0,0) is at the lower left, (1,1) at the upper right of the axis. |
Figure | fig.transFigure | The coordinate system of the graph. (0,0) is at the lower left, (1,1) at the upper right of the graph |
display | None | This is the pixel coordinate system of the display. (0,0) is the lower left corner, and (width, height) is the upper right corner displayed (in pixels). Or you can use (matplotlib.transforms.IdentityTransform()) instead of None. |
Consider the following example -
# Filename : example.py # Copyright : 2020 By w3codebox # Author by: www.oldtoolbag.com # Date : 2020-08-08 axes.text(x, y, "my label")
The theoretical position of the text is located at the data point (x, y). Also known as 'data coordinates'. The placement can be controlled using other transformation objects. For example, if you want to place the above test at the center of the axis coordinate system, please execute the following code line -
# Filename : example.py # Copyright : 2020 By w3codebox # Author by: www.oldtoolbag.com # Date : 2020-08-08 axes.text(0.5, 0.5, 'middle of graph', transform=axes.transAxes)
These transformations can be used for any type of Matplotlib object. The default transformation for ax.text is ax.transData, and the default transformation for fig.text is fig.transFigure.
It is very useful to place text on the axis when placing text on the axis. It may often be necessary to use text bubbles at fixed positions; for example, at the upper left of the axis grid, the position remains fixed when translated or scaled.