I have multiple plots that I would like to display together (in a subplot type distribution), however, my plots need to have a loglog scale. Is there a way to do this?
MATLAB: How to make loglog subplots
loglogsubplot
Related Solutions
Presuming hF is the handle of the figure and hAx is the array of axes handles you saved when you created the subplots, you can do one of several effects depending on just what you want...
- set(hAx(2:3),{'YTickLabel'},{[]}) % remove only labels leaving ticks
- set(hAx(2:3),{'YTick'},{[]}) % remove ticks and labels from y axis
- set(hAx(2:3),{'YColor'},{hF.Color}); % remove the appearance of the y-axes entirely
You can also modify the 'Position' property to increase width of each and LH start point of the two right most to close up the spacing if desired.
Example adjusting limits
hAx=arrayfun(@(ix) subplot(1,3,ix),1:3); % make three subplots
hF=gcf; % get figure handle
set(hAx(2:3),{'YColor'},{hF.Color}) % hide axes for 2, 3
pos=get(hAx,'position'); % return the positions
Above is 3-element cell array for the three subplot axes.
In each position vector, the values are Left, Bottom, Width, Height so right side of axis position is pos(1)+pos(3)
>> pos{:}ans = 0.1300 0.1100 0.2134 0.8150ans = 0.4108 0.1100 0.2134 0.8150ans = 0.6916 0.1100 0.2134 0.8150rt=pos{3}(1)+pos{3}(3)-pos{1}(1); % rightmost axis RH end position
delt=pos{2}(1)-(pos{1}(1)+pos{1}(3)); % delta between 2 and 1; 3 and 2
delt=delt/2; % let's halve the present spacing
wnew=pos{1}(3)+delt; % so make the new width for all 3
pos{1}(3)=wnew;pos{2}(3)=wnew;pos{3}(3)=wnew;pos{2}(1)=pos{1}(1)+pos{1}(3)+delt/2; % set LH position of second,
pos{3}(1)=pos{2}(1)+pos{2}(3)+delt/2; % third; split delta to match
set(hAx(1),'Position',pos{1}) % now set the three new positons
set(hAx(2),'Position',pos{2})set(hAx(3),'Position',pos{3})
I'm certain one could sit down and derive the algebra to compute the LH positions more directly; I just did this by manipulating the corner and width to set the next one at end of previous + the difference.
For comparison, after the above machinations
>> cell2mat(pos)ans = 0.1300 0.1100 0.2471 0.8150 0.3939 0.1100 0.2471 0.8150 0.6579 0.1100 0.2471 0.8150>>
It's observed that what has changed is the first and third columns; the first being Left, the third Width. Width is constant but larger (wider) and Left is adjusted to account but diff(pos(:,1)) is still constant to evenly space each horizontally but leaving the first at same position to leave room for the visible tick labels.
Result is
>>
figureplot3([2953500 2955000],[3805000 3805000],[4150000 4150000],'Linewidth',2),hold onplot3([2955000 2955000],[3805000 3806500],[4150000 4150000],'Linewidth',2) plot3([2955000 2955000],[3805000 3805000],[4150000 4152000],'Linewidth',2) text(2952800,3805000,4150000,'1km','FontSize',12)text(2955000,3807000,4150000,'1km','FontSize',12)text(2955000,3805000,4152500,'1km','FontSize',12)plot3([2962500 2964000],[3820000 3820000],[4150000 4150000],'Linewidth',2)plot3([2964000 2964000],[3820000 3821500],[4150000 4150000],'Linewidth',2) plot3([2964000 2964000],[3820000 3820000],[4150000 4152000],'Linewidth',2) text(2961800,3820000,4150000,'1cm','FontSize',12)text(2964500,3820000,4150000,'1cm','FontSize',12)text(2963500,3820000,4153000,'1cm','FontSize',12)grid onxlim([2952000 2966000])ylim([3804000 3822000])zlim([4150000 4162000])set(gca,'ydir','reverse');
Best Answer