Only include x labels on bottom subplot

조회 수: 5 (최근 30일)
Heidi Hirsh
Heidi Hirsh 2019년 8월 14일
답변: darova 2019년 8월 14일
I am plotting multiple timeseries together over the same time period (x = time). I want to only label the dates for the bottom subplot to simplify the already-crazy plots. Is there a way to just keep the tick marks on the other plots and maybe take out some of the space between plots too?
Here is the code for one of the plots now (sorry! I'm sure I could be doing the plotting in a cleaner way too! I welcome all feedback/criticism!)
f1=figure(1)
ax(1) = subplot(8,1,1)
h=plot(MX,PK.PRESS(9,:),'.','markersize',1,'color',c9)
ylabel('Depth')
set(gca,'fontsize',13)
title('PK Mooring','fontsize',16)
x = datenum('June-4-2018'):7:datenum('Oct-10-2018');
set(gca, 'XTick', x);
datetick('x','mm/dd','keepticks')
ax(2) = subplot(8,1,2)
h=plot(MX,PK.TEMP,'.','markersize',1)
set(h, {'color'}, num2cell(colors, 2));
ylabel('Temp. (\circC)')
set(gca,'fontsize',13)
x = datenum('June-4-2018'):7:datenum('Oct-10-2018');
set(gca, 'XTick', x);
datetick('x','mm/dd','keepticks')
ax(3) = subplot(8,1,3)
h=plot(MX,PK.PH,'.','markersize',1)
% h=plot(MX,PK.PH)
set(h, {'color'}, num2cell(colors, 2));
ylabel('pH')
set(gca,'fontsize',13)
x = datenum('June-4-2018'):7:datenum('Oct-10-2018');
set(gca, 'XTick', x);
datetick('x','mm/dd','keepticks')
ax(4) = subplot(8,1,4)
h=plot(MX,PK.DO,'.','markersize',1)
set(h, {'color'}, num2cell(colors, 2));
ylabel('DO (\mumol/kg)')
set(gca,'fontsize',13)
x = datenum('June-4-2018'):7:datenum('Oct-10-2018');
set(gca, 'XTick', x);
datetick('x','mm/dd','keepticks')
ax(5) = subplot(8,1,5)
h=plot(MX,PK.DOSAT,'.','markersize',1)
set(h, {'color'}, num2cell(colors, 2));
ylabel('O_2 Saturation (%)')
set(gca,'fontsize',13)
x = datenum('June-4-2018'):7:datenum('Oct-10-2018');
set(gca, 'XTick', x);
datetick('x','mm/dd','keepticks')
ax(6) = subplot(8,1,6)
h=plot(MX,PK.SAL,'.','markersize',1)
set(h, {'color'}, num2cell(colors, 2));
ylabel('Salinity')
set(gca,'fontsize',13)
x = datenum('June-4-2018'):7:datenum('Oct-10-2018');
set(gca, 'XTick', x);
datetick('x','mm/dd','keepticks')
ax(7) = subplot(8,1,7)
plot(MX,fluor,'.','Color',[0 .8 .8],'markersize',1);
ylabel('Fluor. (\mumol chla/L)')
legend('OA1 Buoy')
set(gca,'fontsize',13)
x = datenum('June-4-2018'):7:datenum('Oct-10-2018');
set(gca, 'XTick', x);
datetick('x','mm/dd','keepticks')
ax(8) = subplot(8,1,8)
h=plot(MX,PK.PAR,'.','markersize',1)
set(h, {'color'}, num2cell(colors, 2));
ylabel('PAR (\mumol/s/m^2)')
legend('Surface','6.1 mab','5.2 mab','4.4 mab','3.3 mab','2.6 mab','1.5 mab','1.0 mab','0.0 mab',...
'location','southoutside','orientation','horizontal','fontsize',16)
set(gca,'fontsize',13)
x = datenum('June-4-2018'):7:datenum('Oct-10-2018');
set(gca, 'XTick', x);
datetick('x','mm/dd','keepticks')
linkaxes(ax,'x')
  댓글 수: 2
Walter Roberson
Walter Roberson 2019년 8월 14일
Have you looked at the fairly new stackedplot()?
Heidi Hirsh
Heidi Hirsh 2019년 8월 14일
Not yet! I'll look it up!

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

답변 (2개)

KALYAN ACHARJYA
KALYAN ACHARJYA 2019년 8월 14일
편집: KALYAN ACHARJYA 2019년 8월 14일
"Only include x labels on bottom subplot"
ax(8) = subplot(8,1,8)
h=plot(MX,PK.PAR,'.','markersize',1)
set(h, {'color'}, num2cell(colors, 2));
xlabel('data as per') % Add this line
%.........^^ Edit the Text
ylabel('PAR (\mumol/s/m^2)')
Rest are same, just add that line
  댓글 수: 4
KALYAN ACHARJYA
KALYAN ACHARJYA 2019년 8월 14일
편집: KALYAN ACHARJYA 2019년 8월 14일
Remove this
datetick('x','mm/dd','keepticks')
Keep this in last subplot only. Still unable to solve it, please share the complete code and data, so that I can try on it.
KALYAN ACHARJYA
KALYAN ACHARJYA 2019년 8월 14일
편집: KALYAN ACHARJYA 2019년 8월 14일
Try??
f1=figure(1)
ax(1) = subplot(8,1,1)
h=plot(MX,PK.PRESS(9,:),'.','markersize',1,'color',c9)
ylabel('Depth')
set(gca,'fontsize',13)
title('PK Mooring','fontsize',16)
x = datenum('June-4-2018'):7:datenum('Oct-10-2018');
set(gca, 'XTick', x);
ax(2) = subplot(8,1,2)
h=plot(MX,PK.TEMP,'.','markersize',1)
set(h, {'color'}, num2cell(colors, 2));
ylabel('Temp. (\circC)')
set(gca,'fontsize',13)
x = datenum('June-4-2018'):7:datenum('Oct-10-2018');
set(gca, 'XTick', x);
ax(3) = subplot(8,1,3)
h=plot(MX,PK.PH,'.','markersize',1)
% h=plot(MX,PK.PH)
set(h, {'color'}, num2cell(colors, 2));
ylabel('pH')
set(gca,'fontsize',13)
x = datenum('June-4-2018'):7:datenum('Oct-10-2018');
set(gca, 'XTick', x);
ax(4) = subplot(8,1,4)
h=plot(MX,PK.DO,'.','markersize',1)
set(h, {'color'}, num2cell(colors, 2));
ylabel('DO (\mumol/kg)')
set(gca,'fontsize',13)
x = datenum('June-4-2018'):7:datenum('Oct-10-2018');
set(gca, 'XTick', x);
ax(5) = subplot(8,1,5)
h=plot(MX,PK.DOSAT,'.','markersize',1)
set(h, {'color'}, num2cell(colors, 2));
ylabel('O_2 Saturation (%)')
set(gca,'fontsize',13)
x = datenum('June-4-2018'):7:datenum('Oct-10-2018');
set(gca, 'XTick', x);
ax(6) = subplot(8,1,6)
h=plot(MX,PK.SAL,'.','markersize',1)
set(h, {'color'}, num2cell(colors, 2));
ylabel('Salinity')
set(gca,'fontsize',13)
x = datenum('June-4-2018'):7:datenum('Oct-10-2018');
set(gca, 'XTick', x);
ax(7) = subplot(8,1,7)
plot(MX,fluor,'.','Color',[0 .8 .8],'markersize',1);
ylabel('Fluor. (\mumol chla/L)')
legend('OA1 Buoy')
set(gca,'fontsize',13)
x = datenum('June-4-2018'):7:datenum('Oct-10-2018');
set(gca, 'XTick', x);
ax(8) = subplot(8,1,8)
h=plot(MX,PK.PAR,'.','markersize',1)
set(h, {'color'}, num2cell(colors, 2));
xlabel('Add label here');
ylabel('PAR (\mumol/s/m^2)')
legend('Surface','6.1 mab','5.2 mab','4.4 mab','3.3 mab','2.6 mab','1.5 mab','1.0 mab','0.0 mab',...
'location','southoutside','orientation','horizontal','fontsize',16)
set(gca,'fontsize',13)
x = datenum('June-4-2018'):7:datenum('Oct-10-2018');
set(gca, 'XTick', x);
datetick('x','mm/dd','keepticks')
linkaxes(ax,'x')

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


darova
darova 2019년 8월 14일
Shorter version

카테고리

Help CenterFile Exchange에서 Grid Lines, Tick Values, and Labels에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by