How do I plot a second axis which scales with the inverse of the original axis?
19 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
采纳的回答
Star Strider
2015-3-6
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 个评论
Star Strider
2015-3-7
My pleasure! And thank you for the compliment!
Happy kinetic studies! My B.S. was in Chemistry, but back in the phlogiston days.
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!