We can specify the position of text in PyPlot, but how can we read the position of text? For example, I want to know the coordinates of the Figure's title or the Axes X and Y labels.
Pseudo-code:
x, y = PyPlotObject.get_position()
I'm also interested in related text properties such as size, scale and rotation.
import matplotlib.pyplot as plt
import numpy as np
x1 = np.linspace(0.0, 5.0, 100)
y1 = np.cos(2 * np.pi * x1) * np.exp(-x1)
fig, ax = plt.subplots(figsize=(5, 3))
fig.subplots_adjust(bottom=0.15, left=0.2)
ax.plot(x1, y1)
ax.set_xlabel('Time (s)')
ax.set_ylabel('Damped oscillation (V)')
ax.set_title('Oscillation')
plt.show()
    
ax.xaxis.get_label().get_position()will give you the following output:(0.5, 15.72222222222223). Here we see the 0.5 on the x axis (in the middle of the plot). But for the Y coordinate we see something else, I am guessing this is a value that is in another axis coordinate. To transform the 15.7 to a value that is between 0-1, I think you would need to see what the renderer is doingax.title.get_position().