I would like to replicate an Arrhenius plot: it's a semi-log plot presenting something as a function of 1000/T (T being the temperature in Kelvin). This is not very convenient for the reader, so an additional axis with T is required.

I have tried using this solution and this one as well but I always end up with the secondary axis ranging from 0 to 1 instead of ~380 to 710. My guess is I haven't written properly the x coord trafo line.

Here is my MWE

        axis x line*= bottom,
        axis y line*= left,
        ymode = log,
        xlabel={1000/T (1/K)},
        ylabel = phi,
        xmin = 1.4,
        xmax = 2.6,
        ymin = 3e-14,
        ymax = 5e-11
        \addplot[red] {9.39e-9*exp(-37.3e3/(8.314*(1000/x)))};
        axis x line*= top,
        axis y line*= right,
        xlabel={T (K)},
        xtick={500, 600},
        x coord trafo/.code=\pgfmathparse{1000/#1}

And here is the very unsatisfying result

Top x axis ranges from 0 to 1 instead of actual temperatures around 500K

Bonus points if you can make the right-hand side ticks go away or at least correspond to the left-hand ones.


One way of doing this is to make use of the feature that expressions can be given to xticklabel.

For details have a look at the comments in the code. (Please note that I also did some other "improvements" to your code which might be useful.)

% used PGFPlots v1.17
    % (use this `compat` level or higher to make use of the improved axis label positioning)
    % (so we don't have to repeat ourselves we define some variables)
    /pgf/declare function={
    % (moved stuff here which is used in both `axis` environments)
    every axis/.append style={
        % (restrict `domain` to the used region ...
        %  ... and since it is a straight line we only need two `samples`)
        axis x line*=bottom,
        axis y line*=left,
        % (just improved the `axis` labels a bit)
        xlabel={$1000/T$ (1/K)},
        \addplot [red] {9.39e-9*exp(-37.3e3/(8.314*(1000/x)))};
        axis x line*=top,
        axis y line*=right,
        xlabel={$T$ (K)},
        % show the "usual" x-axis
        % we need to add a dummy point to plot the right axis labels
        \addplot [draw=none,fill=none] coordinates {(2,0)};

image showing the result of above code

  • Works like a charm ! Can I still pick which ticks appear on the top axis with xticks={} ? – mackoide Jan 18 at 8:05
  • Great to hear. I think you mean xtick, right? (xticks shouldn't exist.) I don't see why not. (Did you give it a try before asking?) – Stefan Pinnow Jan 18 at 8:48
  • Sorry for the typo, it is indeed xtick={}. I tried it, by simply adding xtick={600, 500, 400}, right before ytick={} It makes the top ticks vanish and throws error "dimension too large". Changing the order of the ticks to xtick={400, 500, 600}, gives the same error. – mackoide Jan 18 at 10:37
  • That's because you need to provide the "1000/T" values, i.e. xtick={1000/400,1000/500,1000/600},. – Stefan Pinnow Jan 18 at 10:59
  • Indeed ! Thanks a lot. – mackoide Jan 18 at 14:16

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.