How do I plot a second axis which scales with the inverse of the original axis?

I'm creating an Arrhenius plot. The x-axis of the Arrhenius plot is 10,000/T in Kelvin. Rarely has there been a less intuitive axis. I want to add a second x-axis which plots temperature in Celsius, which would line up with the values in 10,000/T(K).
The problem here is that the second x-axis needs to scale with the inverse of the original. This is not a linear scale, or a log scale, but a 1/x scale. How do I do this?
So far I have been using addsecondaxis, here is the script which will approximate a second linear x-axis:
axes = gca; % get current axis data
Clim = 10000./axes.XLim - 273.15; % converts the current X axis limits to Celsius in a 1x2 vector
Clim = wrev(Clim); % reverses the vector so that addsecondaxis() won't break
addsecondaxis(Clim); % adds another axis at the top with degrees C
set(gca,'XDir','Reverse'); xlabel('Temperature (°C)') % labels/reverses the T(C) axis
Now I just need a way to get the axis to scale as 1/x rather than linear. Any help would be greatly appreciated.
Using 2014b.

 Réponse acceptée

I’m having a bit of a problem following your code, but you can label your second axis with whatever you want using set with gca and 'XTick' and 'XTickLabel'.
For example:
set(gca, 'XTick', axes.XLim, 'XTickLabel', Clim)
I’m not certain that’s exactly what you want, so experiment with it since I may have misunderstood your variables.

4 commentaires

My issue isn't labeling the axis or setting the ticks. My issue is the scale of the x-axis. MATLAB only seems to be able to create linear or logarithmic scales, whereas I want the second x-axis to have a 1/x scale.
If you specify the 'XTick' locations, it will put the ticks where you want them, and label them as you want them.
You're right, that was it! Thank you so much!
My pleasure! And thank you for the compliment!
Happy kinetic studies! My B.S. was in Chemistry, but back in the phlogiston days.

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by