I want to plot Wavelength and Wavenumbers of one Dataset to one tikzpicture. I found stackexchange: How to have linked axes on plots? but I DONT want to have both axis-ticks aligned to same position. See image: red is plotted but blue does not fit with buttom axes and is unfortunately not plotted.
Like Jakes code:
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\pgfkeys{/pgfplots/.cd,master axis/.style={
scale only axis,
enlarge x limits=false,
axis x line*=bottom,
xticklabel shift=3pt,
after end axis/.code={
\pgfkeys{/pgf/fpu=true,/pgf/fpu/output format=fixed}
\pgfmathparse{\pgfkeysvalueof{/pgfplots/xmin}}
\global\let\masterxmin=\pgfmathresult
\pgfmathparse{\pgfkeysvalueof{/pgfplots/xmax}}
\global\let\masterxmax=\pgfmathresult
\pgfkeys{/pgf/fpu=false}
}
},
slave axis/.style={
scale only axis,enlarge x limits=false,
axis x line*=top,
axis y line=none,
xmin=\masterxmin,xmax=\masterxmax,ymin=0,ymax=1,
scaled x ticks=false,
xtick={1,4,10,20,40,100},
xticklabel={
\pgfkeys{/pgf/fpu}
\pgfmathparse{1/\tick}
\pgfmathprintnumber{\pgfmathresult}
}
}
}
\begin{document}
\begin{tikzpicture}
\begin{axis}[master axis,
ymin=0,ymax=100,
xmin=7,xmax=16,
enlarge x limits=false,
xlabel={Wavelength $\lambda$},
ylabel=Transmissivity
]
\addplot[domain=7:16,samples=100,thick]{-(abs(tan(x*10))-2*rnd)+90};
\end{axis}
\begin{axis}[slave axis,xlabel=Wavenumber 1/$\lambda$]\end{axis}
\end{tikzpicture}
\end{document}
so how to change the code? One posibility is to leave or change
xtick={1,4,10,20,40,100}
but this leads in badly brocken values align with bottom (see Image 2).
I also tried to set to
xmin=0.1428,xmax=0.0625,x dir=reverse % 1/7=0.1428 1/16=0.0625
but this destroys the axis.
I also found stackexchange:Use function to scale x axis but I don't know how to change this because of the reverse counting.
Thanks a lot :-)