Thread Subject: changing x-axis from hour to day

Subject: changing x-axis from hour to day

From: Ka Lee

Date: 28 May, 2008 15:40:17

Message: 1 of 3

Hi, right now, I am doing a plot:

My "y" is hourly-traffic, which has 480 entries. My "x" is
a vector with elements 1 to 480. It represents hours.

plot(x,y)
axis([1,480,0,1])
set(gca,'xTick',0:24:480)
xlabel('\fontsize{10} Hour')
ylabel('\fontsize{10} Traffic)

In this plot, the x-axis shows "24, 48, 72,...,480" at the
corresponding positions.

But now I need to change from hour to day. That is, I want
the x-axis in my plot to show "1, 2, 3,..., 20" in the
place of the hour positions. Could someone show me how to
do that? Thanks!!!

Subject: changing x-axis from hour to day

From: Ka Lee

Date: 28 May, 2008 15:50:20

Message: 2 of 3

Never mind. I've figured it out. It turns out this is
what I need to write:

plot(x,y)
axis([1,480,0,1])
set(gca,'xTick',0:24:480,'XTickLabel',0:1:20)
xlabel('\fontsize{10} Day')
ylabel('\fontsize{10} Traffic)

"Ka Lee" <kaloklee@gmail.com> wrote in message <g1jud1
$6ru$1@fred.mathworks.com>...
> Hi, right now, I am doing a plot:
>
> My "y" is hourly-traffic, which has 480 entries. My "x"
is
> a vector with elements 1 to 480. It represents hours.
>
> plot(x,y)
> axis([1,480,0,1])
> set(gca,'xTick',0:24:480)
> xlabel('\fontsize{10} Hour')
> ylabel('\fontsize{10} Traffic)
>
> In this plot, the x-axis shows "24, 48, 72,...,480" at
the
> corresponding positions.
>
> But now I need to change from hour to day. That is, I
want
> the x-axis in my plot to show "1, 2, 3,..., 20" in the
> place of the hour positions. Could someone show me how
to
> do that? Thanks!!!

Subject: changing x-axis from hour to day

From: Barry Williams

Date: 28 May, 2008 15:56:02

Message: 3 of 3

"Ka Lee" <kaloklee@gmail.com> wrote in message <g1jud1
$6ru$1@fred.mathworks.com>...
> Hi, right now, I am doing a plot:
>
> My "y" is hourly-traffic, which has 480 entries. My "x"
is
> a vector with elements 1 to 480. It represents hours.
>
> plot(x,y)
> axis([1,480,0,1])
> set(gca,'xTick',0:24:480)
> xlabel('\fontsize{10} Hour')
> ylabel('\fontsize{10} Traffic)
>
> In this plot, the x-axis shows "24, 48, 72,...,480" at
the
> corresponding positions.
>
> But now I need to change from hour to day. That is, I
want
> the x-axis in my plot to show "1, 2, 3,..., 20" in the
> place of the hour positions. Could someone show me how
to
> do that? Thanks!!!

Someone will likely come up with something more elaborate,
but the simplest way:

plot(x/24,y)

Barry

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

Public Submission Policy

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.

Contact us at files@mathworks.com