Thread Subject: X axis format in R2007b

Subject: X axis format in R2007b

From: Anish Goorah

Date: 31 Jan, 2008 12:04:02

Message: 1 of 4

I have a year vector which runs from [19974:20064] and i
plot it with another return vector with the following command:

plot(year,return)

It works fine except that when it is displaying the plot it
shows the numbers in standard form on teh x-axis, i.e. it
shows 1.97*10^4, 1.98*10^4 etc. How do i just switch it back
to 19974 as to mean Q4 in 1997? It's the first time I have
had this issue in matlab....

Thanks

Subject: X axis format in R2007b

From: marky

Date: 31 Jan, 2008 13:42:34

Message: 2 of 4

Anish Goorah wrote:
> I have a year vector which runs from [19974:20064] and i
> plot it with another return vector with the following command:
>
> plot(year,return)
>
> It works fine except that when it is displaying the plot it
> shows the numbers in standard form on teh x-axis, i.e. it
> shows 1.97*10^4, 1.98*10^4 etc. How do i just switch it back
> to 19974 as to mean Q4 in 1997? It's the first time I have
> had this issue in matlab....

See the XTickLabel property of an axis. E.g.

x = 1:16;
l = repmat(1997:2000,4,1);
l = num2str(l(:));
l2 = repmat(['Q1';'Q2';'Q3';'Q4'],4,1);
ll = [l,l2];
y = sin(x);
plot(x,y,'.')
set(gca,'XTickLabel',ll)
set(gca,'XTick',x)

Subject: X axis format in R2007b

From: Pekka

Date: 31 Jan, 2008 13:52:01

Message: 3 of 4

"Anish Goorah" <anish.goorah@gmail.com> wrote in message
<fnsdfi$ita$1@fred.mathworks.com>...
> I have a year vector which runs from [19974:20064] and i
> plot it with another return vector with the following
command:
>
> plot(year,return)
>
> It works fine except that when it is displaying the plot
it
> shows the numbers in standard form on teh x-axis, i.e. it
> shows 1.97*10^4, 1.98*10^4 etc. How do i just switch it
back
> to 19974 as to mean Q4 in 1997? It's the first time I have
> had this issue in matlab....
>
> Thanks

You can manually set the XTickLabel property of the axis.
If the XTick positions are ok, then one possibility would be
set(gca,'XTickLabel',int2str(get(gca,'XTick')'))

See documentation: Handle Graphics Objects
for further tweaking

Subject: X axis format in R2007b

From: Steven Lord

Date: 31 Jan, 2008 14:22:16

Message: 4 of 4


"Anish Goorah" <anish.goorah@gmail.com> wrote in message
news:fnsdfi$ita$1@fred.mathworks.com...
>I have a year vector which runs from [19974:20064] and i
> plot it with another return vector with the following command:
>
> plot(year,return)
>
> It works fine except that when it is displaying the plot it
> shows the numbers in standard form on teh x-axis, i.e. it
> shows 1.97*10^4, 1.98*10^4 etc. How do i just switch it back
> to 19974 as to mean Q4 in 1997? It's the first time I have
> had this issue in matlab....

Do you specifically need your ticks in this format or would something like
"Q4-1997" be acceptable? If "Q4-1997" would be acceptable, look at HELP
DATETICK:

http://www.mathworks.com/access/helpdesk/help/techdoc/ref/datetick.html

Depending on the format of your original data, you may need to use DATENUM
to convert your dates from QQ-YYYY format to serial date numbers, using the
first day of each quarter instead of the number of the quarter.

--
Steve Lord
slord@mathworks.com

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

rssFeed for this Thread

Contact us at files@mathworks.com