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:
Becoming crazy to set xticks...

Subject: Becoming crazy to set xticks...

From: Camille Couzi

Date: 14 Feb, 2011 13:08:03

Message: 1 of 5

hello matlabers,
I have a question, about xticks. I have read millions of threads, and still don't undertand why matlab don't want to make the xticks as I want.

I have created a little example here to simplify the program I am working on:
 
x=1:100;
y=randn(100,1);
plot(x,y,'-+')

Now, my xitcks are from 0 to 100. I want xticks from 0 to 400 (for example.)
How do I do that?
I have tried with
set(gca,'XTickLabel',0:400)
set(gca,'XTickLabel',[0:400])

anything works...
I am sure it is a very simple issue... :-(

Thanks in advance for your help!

Camille.

Subject: Becoming crazy to set xticks...

From: Wayne King

Date: 14 Feb, 2011 13:20:05

Message: 2 of 5

"Camille Couzi" <camillecouzi@yahoo.fr> wrote in message <ijb9fj$jfk$1@fred.mathworks.com>...
> hello matlabers,
> I have a question, about xticks. I have read millions of threads, and still don't undertand why matlab don't want to make the xticks as I want.
>
> I have created a little example here to simplify the program I am working on:
>
> x=1:100;
> y=randn(100,1);
> plot(x,y,'-+')
>
> Now, my xitcks are from 0 to 100. I want xticks from 0 to 400 (for example.)
> How do I do that?
> I have tried with
> set(gca,'XTickLabel',0:400)
> set(gca,'XTickLabel',[0:400])
>
> anything works...
> I am sure it is a very simple issue... :-(
>
> Thanks in advance for your help!
>
> Camille.

Hi Camille, do you want something like this?

x=1:100;
y=randn(100,1);
plot(x,y,'-+')
axis([0 400 -3 3])


Wayne

Subject: Becoming crazy to set xticks...

From: Camille Couzi

Date: 14 Feb, 2011 13:31:03

Message: 3 of 5

> Hi Camille, do you want something like this?
>
> x=1:100;
> y=randn(100,1);
> plot(x,y,'-+')
> axis([0 400 -3 3])
>
>
> Wayne

Hi wayne
thanks for replying so quickly!!!!
In fact no, because doing what you propose you have 0 to 400 in the xaxis (you have used the xlim property), but as you see the graph only goes from 0 to100. I want to see x ticks going from 0 to 400 and the graph filling all the axes. I hope my explanation is clear, sorry my english is a little bit bad... :-)
thanks for your help!

Subject: Becoming crazy to set xticks...

From: Wayne King

Date: 14 Feb, 2011 13:44:05

Message: 4 of 5

"Camille Couzi" <camillecouzi@yahoo.fr> wrote in message <ijbaqn$h3e$1@fred.mathworks.com>...
> > Hi Camille, do you want something like this?
> >
> > x=1:100;
> > y=randn(100,1);
> > plot(x,y,'-+')
> > axis([0 400 -3 3])
> >
> >
> > Wayne
>
> Hi wayne
> thanks for replying so quickly!!!!
> In fact no, because doing what you propose you have 0 to 400 in the xaxis (you have used the xlim property), but as you see the graph only goes from 0 to100. I want to see x ticks going from 0 to 400 and the graph filling all the axes. I hope my explanation is clear, sorry my english is a little bit bad... :-)
> thanks for your help!

Then you want to define your x vector differently. You have your x vector defined from 1:100 in steps of 1, then you call plot with the plot(x,y) syntax.

x = 1:4:400;
y = randn(100,1);
plot(x,y,'-+');


Wayne

Subject: Becoming crazy to set xticks...

From: Camille Couzi

Date: 14 Feb, 2011 13:59:04

Message: 5 of 5

:-)
I was sure it was going to be sthg really easy...
thanks!

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