hamster
hamster

Reputation: 69

matplotlib scatter plot using relative coordinate?

I notice that there is an option of figure fraction etc for annotating text. Is there an option for scatter? I have data points generated by a program that are in figure fraction scale. They will be overplotted onto an image with sky coordinate. The transformation from pixel scale to sky coordinate will be a bit complicated.

Upvotes: 2

Views: 509

Answers (1)

Yann
Yann

Reputation: 35513

Checkout the transform tutorial. You want to first transform from figure units to display units using fig.transFigure, then do the inverse transform to data units, using ax.transData.inverted(). You can make a single transform using transform pipeline:

FigToData = ax.transData.inverted() + fig.transFigure

This can then be used to get values in data units by implementing the transform() method:

xData, yData = FigToData.transform(.1, .1)

Read the tutorial for more detail.

Upvotes: 4

Related Questions