MATLAB Answers

linkaxes on logarithmic scale is off

4 views (last 30 days)
Reinder Dorman
Reinder Dorman on 9 Sep 2020
Commented: Reinder Dorman on 14 Sep 2020
Hey guys,
I'm making a 4x4 subplot, with each plot having a log x axis. I use linkaxis to align everything (like I normally do in similar situations), but for some reason now with the log scale it's weird. The XLim property is the same for each plot, but for some reason some plots are off (see attached picture). The plots that are off are always the ones with higher x-values. I noticed the XTicks are different, but when setting these the same for all subplots the problem still persists. (Note: the attached picture is after setting XTicks the same for all plots)
Am I missing some log-scale propertie that should fix this? Googling this behavior came up blank, so I'm not so sure what's going on here. Any tips are appreciated!
Code snippet:
% kernel density plot
c=1;
figure;
for idx = 1:numel(areas)
for jdx = 1:numel(areas)
h(c) = subplot(size(data,1),size(data,2),c);
if idx == jdx; c=c+1; axis off; continue; end % skip diagonal
[f,xi] = ksdensity(data{idx,jdx});
semilogx(xi,f);
grid minor;
c=c+1;
end
end
linkaxes(h)
[h.XTick] = deal([10 100 1000]);

  0 Comments

Sign in to comment.

Answers (1)

VBBV
VBBV on 9 Sep 2020
Edited: VBBV on 9 Sep 2020
Try this way.
%if true
% code
%end
% kernel density plot
c=1;
figure;
for idx = 1:numel(areas)
for jdx = 1:numel(areas)
h(c) = subplot(size(data,1),size(data,2),c);
if idx == jdx; c=c+1; axis off; continue; end % skip diagonal
[f,xi] = ksdensity(data{idx,jdx});
semilogx(xi,f);
grid minor;
c=c+1;
end
end
linkaxes(h,'x'); %

  1 Comment

Reinder Dorman
Reinder Dorman on 14 Sep 2020
Hey Vasishta, thanks for the tip.
If I see it correctly, you mean the addition of 'x' at "linkaxes", correct?
If so, that unfortunately doesn't help this case.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!

Translated by