Accéder au contenu principal


Affichage des articles du mai, 2014

Plotting a data set with two different units in Matplotlib

In my thesis, I handle polarimetric observations of Venus with Venus Express. Because of the north polar elliptical orbit of the spacecraft, when observing in nadir there is a link between the phase angle and the latitude of observation 1 . Though, this is not always easy to understand so I found the need to plot my polarimetric measurements as a function of phase angle, but also as a function of latitude. I was thinking of plotting the phase angle on the bottom x-axis, and the latitude on the top x-axis. Can we do that in Python/Matplotlib?  Of course you can! Matplotlib has brilliant functions called twinx and twiny that take an axis object and duplicate it keeping the same x or y axis that the original. Therefore only the x/y axis is editable as the other is ruled by the original axes. This can be used to plot two independent curves with different y-axis, but also to plot one value with two units (e.g. Celsius degrees and Farenheit degrees). In the latter case, the relat