Only include x labels on bottom subplot

4 次查看(过去 30 天)
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 个)

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 中查找有关 Holidays / Seasons 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by