MATLAB Answers

Mos_bad
0

multiple logarithmic x-axes

Asked by Mos_bad
on 17 Jul 2019
Latest activity Edited by Shashank Sharma on 17 Jul 2019
I need to draw two plots with multiple logarithmic axes in the same figure. For clarification, I want two log-axes (one on top one in bottom) with the same y axis scale. attached is the current plot I got. I need to separate mu_s and mu_d axes.

  2 Comments

KSSV
on 17 Jul 2019
loglog ??
Mos_bad
on 17 Jul 2019
attached is the plot. I want to plot it with multiple x-axes. I mean to separate mu_s and mu_d

Sign in to comment.

1 Answer

Answer by Shashank Sharma on 17 Jul 2019

  2 Comments

Mos_bad
on 17 Jul 2019
this document is about linear axes
The example is provided using the linear axes.
You can always do the same for the semilog or the loglog plot.
Here is an example,
x = 0:1000;
y = log10(x);
semilogx(x,y);
ax1 = gca;
ax1_pos = ax1.Position;
ax2 = axes('Position',ax1_pos,...
'XAxisLocation','top',...
'YAxisLocation','left',...
'Color','none',...
'YColor', 'none');
x = 0:1000;
y = 2*log10(x);
hold on;
semilogx(ax2, x,y);
ax1.YLim = max(ax1.YLim, ax2.YLim);
In the above code there are two plots on the same figure.
The yaxis is made transparent on the second axes and in the last line the limit of the Y-axis is changed to the max of both the axes so that it fits both plots in the same figure.
If you instead require a log-log plot use the loglog function instead of the semilog. It works on similar principles.

Sign in to comment.