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

command for which the label on the x axis is not shown

Asked by Locks on 18 May 2013

Hi,

I am looking for a command so that there are no values on the x axis shown.

I tried this;

set(gca,'xtick',[])

but it's not working, any idea

1 Comment

per isakson on 18 May 2013

Any warning or error message?

Locks

Products

No products are associated with this question.

3 Answers

Answer by per isakson on 18 May 2013
Accepted answer

It works here (R2012a)

    %%
    sdn             = [ 1 : 6 ] + 735370;
    date_strings    = datestr( sdn, 'dd-mmm-yyyy' );
    %%
    plot( [1:6] )
    axh = gca;
    %%
    set( axh, 'XTickLabel', date_strings ) 
    %%
    set( axh, 'XTick', [] ) 

There are neither ticks nor labels on the x-axis.

1 Comment

per isakson on 18 May 2013

This example is according to the documentation and it works here.

What could the reason be that it doesn't work for you?

  • you have more than one axes object and the current axes is an "other" axes; not the one you think

Restart Matlab and run this example. I would very surprised it it behaves differently compare to what I see.

per isakson
Answer by Walter Roberson on 18 May 2013

Try

set(gca, 'xticklabel', '')

1 Comment

Locks on 18 May 2013

that does not work either

dates=datenum(dataSet(:,1));

this does still show some values on the x axis, what am I doing wrong?

%SPX
SPX=dataSet(:,2);
%VIX
VIX=dataSet(:,3);
plotyy(dates,SPX,dates,VIX);
set(gca, 'xticklabel', '')
Walter Roberson
Answer by Image Analyst on 18 May 2013

Like I said in your duplicate question:

plot(1:10); % Plot some arbitrary sample data.
set(gca, 'xtick', [-inf inf]); % Turn off x-axis.

3 Comments

Locks on 18 May 2013

sorry for the duplicate, I first thought that I haven't saved the first one. however, using your code doesn't work either. do I miss something?

I tried this:

dates=datenum(dataSet(:,1));
%SPX
SPX=dataSet(:,2);
%VIX
VIX=dataSet(:,3);
plotyy(dates,SPX,dates,VIX);
set(gca, 'xtick', [-inf inf]);
Image Analyst on 18 May 2013

Explain why it does not work. It plots something in an axes control "where there are no value displayed on the x axis" just like you asked for.

Give me something we can run:

Undefined variable dataSet.
Error in test3 (line 1)
dates=datenum(dataSet(:,1)); 
Walter Roberson on 18 May 2013

What you are missing is that you used plotyy() without mentioning it to us. plotyy() generates two axes, and makes no promises about what gca() will refer to afterwards. You need to save the output of the plotyy() call and use the appropriate axes from what is returned.

Image Analyst

Contact us