Only include x labels on bottom subplot

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 comentarios

Walter Roberson
Walter Roberson el 14 de Ag. de 2019
Have you looked at the fairly new stackedplot()?
Heidi Hirsh
Heidi Hirsh el 14 de Ag. de 2019
Not yet! I'll look it up!

Iniciar sesión para comentar.

Respuestas (2)

KALYAN ACHARJYA
KALYAN ACHARJYA el 14 de Ag. de 2019
Editada: KALYAN ACHARJYA el 14 de Ag. de 2019
"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 comentarios

Heidi Hirsh
Heidi Hirsh el 14 de Ag. de 2019
Do I need to remove the lines of subplots that describe the ticks and labels currently?
Heidi Hirsh
Heidi Hirsh el 14 de Ag. de 2019
adding the line: " xlabel('data as per') " just adds that label to the x axis in addition to the dates. I want to remove the dates for all subplots except the bottom one. And ideally I also want to remove the space where the dates would be labels to make the figures slightly smaller.
KALYAN ACHARJYA
KALYAN ACHARJYA el 14 de Ag. de 2019
Editada: KALYAN ACHARJYA el 14 de Ag. de 2019
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 el 14 de Ag. de 2019
Editada: KALYAN ACHARJYA el 14 de Ag. de 2019
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')

Iniciar sesión para comentar.

Etiquetas

Preguntada:

el 14 de Ag. de 2019

Respondida:

el 14 de Ag. de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by