I would like to create an Arrhenius plot. Arrhenius plots are made by plotting k versus 1/T. I have poached a photo of a “typical” Arrhenius plot from the web (see image). Because 1/T is an inconvenient unit it is typical to the temperature (T) on the top x axis.
How do I put in a second (top) x-axis? Note the non-linaear scale.
My variables are k, T and T_reciprocal.

 채택된 답변

Chunru
Chunru 2022년 1월 14일
편집: Chunru 2022년 1월 15일

0 개 추천

Not sure your equation. But you can modify the following to produce the plot:
x = linspace(2.5, 4, 20); % x corrdinate
y = 20.2 -1589.6 * x; % your equation
ax1 = axes;
plot(ax1, x, y);
ax1.Box = 'off'; % update: turn off extra ticks
% create a second axis
ax2 = axes('Position', ax1.Position, 'Color', 'none', 'YTick', [], 'XAxisLocation', 'top', 'YTick', [], ...
'XDir', 'reverse', 'XLim', 1000./flip(ax1.XLim)-273);
TC = (-20:20:120); % ticks at T deg C
xTC = 1000./(TC + 273); % Corresponding x
% map xTc onto TC
xTCmap = (xTC - ax1.XLim(1))*(-diff(ax2.XLim)/diff(ax1.XLim)) + ax2.XLim(2)
xTCmap = 1×8
-18.2569 10.6996 35.7031 57.5112 76.6997 93.7139 108.9035 122.5471
ax2.XTick = xTCmap;
ax2.XTickLabel = TC;
ax2.YAxisLocation = 'right'; % Update: move yaxis of ax2 to right
ax2.YTick = [];
xlabel(ax1, "1000/T (K^{-1})")
xlabel(ax2, "Temperature (^\circ C)");
ax1.Position(4) = ax1.Position(4) - 0.1; % Update: make space on top
ax2.Position(4) = ax2.Position(4) - 0.1;

댓글 수: 5

ASC
ASC 2022년 1월 14일
This is great. Thanks you very much Chunru!
When I run the code on my data I have two probelms.
x = 1000./(T(1:end)+273.15); % my data
y = log(V(1:end)); % my data
ax1 = axes;
plot(ax1, x, y);
% create a second axis
ax2 = axes('Position', ax1.Position, 'Color', 'none', 'YTick', [], 'XAxisLocation', 'top', 'YTick', [], ...
'XDir', 'reverse', 'XLim', 1000./flip(ax1.XLim)-273);
TC = (0:100:500); % ticks at T deg C
xTC = 1000./(TC + 273); % Corresponding x
% map xTc onto TC
xTCmap = (xTC - ax1.XLim(1))*(-diff(ax2.XLim)/diff(ax1.XLim)) + ax2.XLim(2);
% xTCmap = 1×8
% -18.2569 10.6996 35.7031 57.5112 76.6997 93.7139 108.9035 122.5471
ax2.XTick = xTCmap;
ax2.XTickLabel = TC;
xlabel(ax1, "1000/T (K^{-1})")
xlabel(ax2, "Temperature (^\circ C)");
One problem is that there are extra ticks on the upper x-axis (see plot).
The other probelm is that the upper axis label is cutoff.
Can you make suggestions for these two problems? Thanks so much.
Chunru
Chunru 2022년 1월 15일
See the update above for solving these two problems.
ASC
ASC 2022년 1월 20일
Thanks again for your help.
This solved the space-up-top-problem. But I still have the problem of there being extra ticks on the top y-axis. Any thoughts? Am I missing something. My Current code is:
figure
ax1 = axes;
plot(ax1, x, y);
% create a second axis
ax2 = axes('Position', ax1.Position, 'Color', 'none', 'YTick', [], 'XAxisLocation', 'top', 'YTick', [], ...
'XDir', 'reverse', 'XLim', 1000./flip(ax1.XLim)-273.15);
TC = (0:100:500); % ticks at T deg C
xTC = 1000./(TC + 273.15); % Corresponding x
% map xTc onto TC
xTCmap = (xTC - ax1.XLim(1))*(-diff(ax2.XLim)/diff(ax1.XLim)) + ax2.XLim(2);
ax2.XTick = xTCmap;
ax2.XTickLabel = TC;
% ax2.YAxisLocation = 'right'; % Update: move yaxis of ax2 to right
% ax2.YTick = [];
xlabel(ax1, "1000/T (K^{-1})")
xlabel(ax2, "Temperature (\circ C)");
ylabel('ln(V)')
ax1.Position(4) = ax1.Position(4) - 0.1; % Update: make space on top
ax2.Position(4) = ax2.Position(4) - 0.1;
The code:
ax2.YAxisLocation = 'right'; % Update: move yaxis of ax2 to right
ax2.YTick = [];
Moved the y-axis labe to the right side of the plot.
Can you post your code and make it executable so that I can run here and see what is problem?
You need the following to turn off the extra ticks. When box is on, the x-axis ticks will show up on both bottom and top.
ax1.Box = 'off'; % update: turn off extra ticks
Walter Roberson
Walter Roberson 2023년 1월 2일
Dustin Mangus comments to @Chunru about the Answer:
The right side of the upper x-axis is on a moving scale based on the TC array that you define. It is adjustable and seem to only be accurate at the y-axis. This means that for all higher temperatures (further to the left) are inaccurate unless TC is adjusted precisely. I give this code a 3/10.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

ASC
ASC 2022년 1월 21일

0 개 추천

I missed this addtional line in your code. Adding
ax1.Box = 'off'; % update: turn off extra ticks
solved the problem. Thank you very much for you help.

카테고리

도움말 센터File Exchange에서 Mathematics에 대해 자세히 알아보기

제품

릴리스

R2021a

질문:

ASC
2022년 1월 13일

댓글:

2023년 1월 2일

Community Treasure Hunt

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

Start Hunting!

Translated by