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.

quick paint example :-)

Thank you :-)

I didn't find the answer yet with google :-(

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:



    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 zerofill,
    no markers,
    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};   


  • You can start from this tex.stackexchange.com/questions/53029/… – percusse 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??!!... – Thomas 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. – percusse Jul 9 '13 at 19:56

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


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

    \addplot[draw=none,no marks] table \mytable;
    axis y line*=right,
    ylabel={\si{\degree F}},
    axis x line=none,
    \addplot table \mytable;

enter image description here

  • Thank you "percusse" for this great and simple solution :-) – Thomas Jul 18 '13 at 18:17
  • @Thomas My pleasure :) – percusse Jul 18 '13 at 18:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.