I'm trying to make a plot with two corresponding y-axis. What I would like is to have the value in one unit on the left y-axis (e.g. meters) and the corresponding value in another units (e.g. inches) on the left y-axis. I managed to do this in this case with meters and inches.
However, things do not work so easily when the conversion is not as obvious as just multiplying by something. In my case I'm trying to plot flux and magnitude. The formula to go from flux to magnitude is: 23.9 - log(flux).
And what worked when I plotted meters and inches does not work anymore. Here is my code:
host = host_subplot(111)
host.set_xlim((0.1,5))
host.set_ylim((1.,50.))
par1 = host.twinx()
par1.set_ylim((23.899999999999999, 19.652574989159952)) # Converting the ylim from flux to mag
host.set_xlabel('Wavelength (Microns)')
host.set_ylabel('Flux density ($\mu$Jy)')
par1.set_ylabel("Magnitude ")
host.errorbar(x, flux, fmt='rx' , xerr=errx, yerr = errorFlux)
par1.errorbar(x, mag, fmt='bx', xerr=errx, yerr=errorMag)
If this worked the two plots should superimpose, but they do not (and again, I made this work when doing something similar from meters to inches). I suspect this as something to do with the log, but when setting the scale to log it is even worse.