Skip to content Skip to sidebar Skip to footer

Matplotlib Axis Text Coordinates Inconsistency?

I'm working on a piece of code to automatically align x-axis labels for a variable number of subplots. When I started having trouble setting label positions manually, I checked to

Solution 1:

You're understanding the transforms correctly, but there's a caveat to using display coordinates before the plot has been displayed.

The short answer is that putting in a call to plt.draw() before your code snippet above will fix your immediate problem.

You're trying to link the different axes display system through display coordinates. However, before the plot has been drawn the first time, the renderer isn't fully initialized yet, and the display coordinates don't have much meaning.

Can you elaborate a bit more on what you're trying to do? There may be an easier way.

Alternatively, if you want to avoid the extra draw, you can link things through figure coordinates before the plot has been drawn. (They're well defined regardless.)

Post a Comment for "Matplotlib Axis Text Coordinates Inconsistency?"