Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
HELP. The XTickLabel is missing!!

Subject: HELP. The XTickLabel is missing!!

From: Kuo-Hsien

Date: 2 Feb, 2011 19:45:05

Message: 1 of 3

Dear all,

I have no idea why the XTickLabel is missing. Can you please give me a hint?

Thank you.

subplot3 = subplot(2,1,2,'Parent',figure6,'ZColor',[1 1 1],'YColor',[1 1 1],'XColor',[1 1 1],'FontSize',14,'Color',[0 0 0]);
box('on'); grid('on'); hold('all');
x1 = tv_hh_09; x2 = tv_hh_09; y1 = rs_hh; y2= ST_hh_layer12;
[AX,H1,H2] = plotyy(x1,y1,x2,y2,'plot');hold on;
axes(AX(1)); n = datenum('10-June-2009', 'dd-mmm-yyyy');set(gca,'XLim',[n n+14]);
set(gca,'XTickLabelMode','manual','XTickMode','manual')
xData=linspace(n,n+14,14+1);
set(gca,'XTick',xData);datetick('x','dd','keepticks');set(gca,'FontSize',14)
axes(AX(2)); n = datenum('10-June-2009', 'dd-mmm-yyyy');set(gca,'XLim',[n n+14]);
set(gca,'XTickLabelMode','manual','XTickMode','manual')
xData=linspace(n,n+14,14+1);
set(gca,'XTick',xData);datetick('x','dd','keepticks');set(gca,'FontSize',14)
set(H1,'Color','g','LineWidth',2,'LineStyle','-')
set(H2,'Color','g','LineWidth',2,'LineStyle','--')
set(AX(1),'YLim',[0 25],'YTick',[0:5:25],'YAxisLocation','left','FontSize',14,'YColor', [1 1 1]);
set(AX(2),'YLim',[0 25],'YTick',[0:5:25],'YAxisLocation','right','YTickMode','auto','FontSize',14,'YColor', [1 1 1]);
set(get(AX(1),'Ylabel'),'String','R_s','FontSize',14,'Color',[1 1 1])
hold on
%
x3 = tv_hh_09; x4 = tv_hh_09; y3 = Rh_mmolm2s1_hh; y4 = ST_hh_obs;
[AX,H3,H4] = plotyy(x3,y3,x4,y4,'plot');hold on;
axes(AX(1)); n = datenum('10-June-2009', 'dd-mmm-yyyy');
set(gca,'XLim',[n n+14]);
set(gca,'XTickLabelMode','manual','XTickMode','manual')
xData =linspace(n,n+14,14+1);
set(gca,'XTick',xData);datetick('x','dd','keepticks');set(gca,'FontSize',14)
axes(AX(2));n = datenum('10-June-2009', 'dd-mmm-yyyy');set(gca,'XLim',[n n+14]);
set(gca,'XTickLabelMode','manual','XTickMode','manual')
xData = linspace(n,n+14,14+1);
set(gca,'XTick',xData);datetick('x','dd','keepticks');set(gca,'FontSize',14)
set(H3,'Color','r','Marker','o','LineStyle','none')%,'DisplayName','R_{s} obs'
set(H4,'Color','r','Marker','o','LineStyle','none')%,'DisplayName','ST obs'
set(AX(1),'YLim',[0 25],'YTick',[0:5:25],'YAxisLocation','left','YColor', [1 1 1]);
set(AX(2),'YLim',[0 25],'YTick',[0:5:25],'YAxisLocation','right','YTickMode','auto','YColor', [1 1 1]);
ylabel('ST (^{o}C)','FontSize',14,'Color',[1 1 1]);
hold on

Subject: HELP. The XTickLabel is missing!!

From: Steven_Lord

Date: 2 Feb, 2011 20:41:21

Message: 2 of 3



"Kuo-Hsien" <mchangks@hotmail.com> wrote in message
news:iicc81$6m1$1@fred.mathworks.com...
> Dear all,
>
> I have no idea why the XTickLabel is missing. Can you please give me a
> hint?
> Thank you.
>
> subplot3 = subplot(2,1,2,'Parent',figure6,'ZColor',[1 1 1],'YColor',[1 1
> 1],'XColor',[1 1 1],'FontSize',14,'Color',[0 0 0]);
> box('on'); grid('on'); hold('all');
> x1 = tv_hh_09; x2 = tv_hh_09; y1 = rs_hh; y2= ST_hh_layer12;
> [AX,H1,H2] = plotyy(x1,y1,x2,y2,'plot');hold on;
> axes(AX(1)); n = datenum('10-June-2009', 'dd-mmm-yyyy');set(gca,'XLim',[n
> n+14]);

*snip*

Once you've used PLOTYY, you should neither use AXES to make one of those
axes the current axes nor use GCA. Use AX instead to refer to the axes
handle explicitly. In this case, change BOTH axes to use the same limits
and you should be okay.

Changing the Y limits or ticks as you did later in your code, however, is a
bad idea as the two axes created by PLOTYY will likely become out of sync
with one another.

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: HELP. The XTickLabel is missing!!

From: Kuo-Hsien

Date: 4 Feb, 2011 07:03:03

Message: 3 of 3

Hi steve,

The figure looks much better, but the bottom line of "box" is missing.

Do you know why it occurred?

Here is the new code:

subplot3 = subplot(2,1,2,'Parent',figure6,'ZColor',[1 1 1],'YColor',[1 1 1],'XColor',[1 1 1],'FontSize',14,'Color',[0 0 0]);
box('on'); grid('on'); hold('all');
[AX1,H1,H2] = plotyy(x1,y1,x2,y2,'plot');hold on;
n = datenum('10-July-2009', 'dd-mmm-yyyy');set(AX1(1),'XLim',[n n+14]);
n = datenum('10-July-2009', 'dd-mmm-yyyy');set(AX1(2),'XLim',[n n+14]);
set(H1,'Color','g','Marker','.','MarkerSize',8,'LineStyle','none')
set(H2,'Color','g','Marker','.','MarkerSize',8,'LineStyle','none')
set(AX1(1), 'xTickLabel','')
set(AX1(2), 'xTickLabel','')
hold on
%
[AX2,H3,H4] = plotyy(x3,y3,x4,y4,'plot');hold on;
n = datenum('10-July-2009', 'dd-mmm-yyyy');set(AX2(1),'XLim',[n n+14]);
n = datenum('10-July-2009', 'dd-mmm-yyyy');set(AX2(2),'XLim',[n n+14]);
set(H3,'Color','r','Marker','o','MarkerSize',5,'LineStyle','none')
set(H4,'Color','r','Marker','o','MarkerSize',5,'LineStyle','none')
set(AX2(1), 'xTickLabel','')
set(AX2(2), 'xTickLabel','')
set(AX2(1),'XTickLabelMode','manual','XTickMode','manual');
xData=linspace(n,n+14,14+1);
set(AX2(1),'XTick',xData,'Color','none');
datetick('x','dd','keepticks');
set(AX2(2),'XTickLabelMode','manual','XTickMode','manual');
xData=linspace(n,n+14,14+1);
set(AX2(2),'XTick',xData,'Color','none');
datetick('x','dd','keepticks');
hold off

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us