subplots overlap each other
7 views (last 30 days)
Show older comments
I have a series of 8 subplots [4 2] and between labeling axes and subplot titles all of the plots overlap one another. I'm a little unclear as to the best method of getting everything on the page without the elements interfering with each other. Can anyone make a suggestion. Result and code included.
% function[] = chartSubplotProfiles2(year, month, day, dataT, dataRH)
% The date is set up in the next three lines
year = 2011
month = 9
day = 16
% A structure has been built which contains signal profiles and urban
% boundary layer heights
load SPBLH_final
% a struct has been built which contains temperature and virtual
% temperature data
load radiometerData
% an 1D array of dates is extracted from the SPBLF_final struct
for i = 1:108
clearDays(i) = SPBLH(i). LSCClearDays;
end
% The index of the desired date is created so that the data from that day
% can be extracted from the SPBLH_final struct
SIndex = find(clearDays == datenum(year, month, day));
PBLH = SPBLH(SIndex).PBLH
% Since each time step is on half an hour, the indices only request data
% for each hour
indices = [1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47];
% the data is called
PBLH = PBLH(indices);
SNR = fixgaps(SPBLH(SIndex).SNR);
LEVELS = SPBLH(SIndex).LEVELS;
TIME = SPBLH(SIndex).TIME(indices);
% a function is called which returns Virtual temperature and temperature.
% The variable for hieight levels above ground is also called
[~, ~, VT, thetaV, ~, ~, ~, ~, ~, ~, ~, ~, hagl, ~] = thermoDynamicVariables(year, month, day, dataT, dataRH);
if all(isnan(VT))
return
else
count = 0;
% We build three figures
for j = 1:3
% try
figure(j)
% we build 8 subplots for each figure
for i = 1:8;
TH = VT(:, i+count);
thetaVH = thetaV(:, i+count);
haglV = [0; hagl];
% 2 asex are place one on top of the other for each
% subplot space
h = subplot(4,2,i);
line(thetaVH, haglV + 47, 'Color','k', 'Marker', '*');
hold on;
set(h, 'XColor','k','YColor', 'b', 'YLim',[0,2200], ...
'XLim', [275 295]);
line(275:295, repmat(PBLH(i + count) + 29, [1 21]), 'Color','b');
line(TH, haglV + 47, 'Color', 'k', 'Marker', '^');
line(SNR(:,i + count), LEVELS, 'Color', 'r')
xlabel('Temperature');
ylabel('height above ground');
ax2 = axes('Position', get(h, 'Position'), ...
'XAxisLocation','top', 'YAxisLocation','right', ...
'Color','none', 'XColor','r','YColor', 'r', ...
'YLim',[0,2200], 'XLim', [-30 30]);
line(SNR(:,indices(i + count)), LEVELS, 'Color', 'r')
line(TH, haglV + 47, 'Color', 'k', 'Marker', '^');
line(thetaVH, haglV + 47, 'Color','k', 'Marker', '*');
line(275:295, repmat(PBLH(i + count) + 29, [1 21]), 'Color','b');
xlabel('Signal to noise (dB)');
ylabel('height above ground');
if i == 1
legend('SNR', 'VT', 'VPT', 'PBL height', ...
'Position', [280, 9.1, 0.4, 1], ...
'Units', 'normalized', 'Orientation', 'horizontal')
end
hold off;
theTitle = strcat('Fig. ', num2str(i), 'Comparative profiles ', ...
datestr(datenum(year, month, day, i-1 + count, 0, 0), 'HH:MM PM'))
h2 = title(theTitle, 'Fontsize', 10);
end
% We set up the .eps file
thepath = ['../images/profiles/comparison/profile_', ...
datestr(datenum(year, month, day),'yyyy-mm-dd'),'part',num2str(j), '.eps'];
set(gcf, 'PaperPositionMode', 'manual', 'PaperUnits', 'inches', 'PaperPosition', ...
[0.25,0.25,8.0, 10.5],'PaperType', 'USLetter', 'PaperOrientation', 'portrait');
saveas(gcf,thepath,'psc2');
% close all;
count = count + 8;
% catch
% break
% end
end
end
0 Comments
Answers (0)
See Also
Categories
Find more on Subplots in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!