Convert Axis ⇔ Data coordinates systems

To get transformations from the Axes instance ax, you can use

axis_to_data = ax.transAxes + ax.transData.inverted()
points_data = axis_to_data.transform(points_axis)
data_to_axis = axis_to_data.inverted()
numpy.testing.assert_allclose(points_axis, data_to_axis.transform(points_data))

Leave a Comment