# pgfplots: two axis for one dataset e.g. °C and °F

I want to plot ONE dataset in a pgfplots and use TWO axis with different units on each axis. For example I have one dataset with temperature and want to print a °C scale on the left and a °F on the right.

Thank you :-)

PS: This is such a great platform and it helps me so much - thanks for all the other answers on this side :-)

This is my code so far with the left axis:

\documentclass[a4paper,10pt]{article}
\usepackage{pgfplots}

\begin{document}

\begin{tikzpicture}
\begin{axis}[
xmin=0, xmax=100, %- show range
ymin=345.95, ymax=346.17, %- show range
domain=0:100, %- calc range
ytick={346.16,346.11,...,340}, %- labels on the left side
y tick label style={
/pgf/number format/.cd,
fixed,
fixed zerofill,
precision=2,
/tikz/.cd
},
samples=200,
no markers,
enlargelimits=false,
xlabel={x-axis},
ylabel={Temperature T[K]},
]
\addplot gnuplot { (346.16 - 0.002 * x)} ;
\addplot gnuplot [style=densely dotted] { 346.16 }
node[below left] at (axis cs:100,346.16) {$73^\circ$C};

\end{axis}\end{tikzpicture}

\end{document}

• You can start from this tex.stackexchange.com/questions/53029/… Jul 9 '13 at 19:49
• thank you "percusse" but I do not understand your hint because I do not want to add two datasets! I only want two axis for one dataset??!!... Jul 9 '13 at 19:54
• You don't need to have two data sets. The axes should overlap to give the two ordinate look. You can modify one of the axis without drawing anything with no x axis ticks etc. If you add a simple example with the data set people can react much faster. Jul 9 '13 at 19:56

Here is a simple example though I've used the Fahrenheit instead of Kelvin.

\documentclass{article}
\usepackage{pgfplots,siunitx}
\pgfplotsset{compat=1.8}

x celc
0 346.16
20 346.11
40 346.06
60 346.01
80 345.96
}\mytable

\begin{document}
\begin{tikzpicture}
\begin{axis}[ylabel={\si{\degreeCelsius}}]
\end{axis}
\begin{axis}[
axis y line*=right,
ylabel={\si{\degree F}},
yticklabel={\pgfmathparse{9*\tick/5+32}\pgfmathprintnumber[fixed,precision=2]\pgfmathresult},
axis x line=none,
]