For Programmers: Free Programming Magazines  


Home > Archive > Matlab > January 2008 > Multiple annual line plots









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Multiple annual line plots
Robert

2008-01-29, 8:14 pm

Generally, I would like to know how to plot many years of
annual time series data on the same plot (i.e. from Jan 1 to
Dec 31 on the x-axis).

I have a column of dates (daily observations -
1968/01/01...) and a column with the variable Q. I have
imported the data and have established the vectors (y, m, d,
Q). I was hoping there was some sort of grouping function I
could use on y and plot associated values of Q.

Thoughts?
Walter Roberson

2008-01-29, 11:05 pm

In article <fnok6a$aib$1@fred.mathworks.com>,
Robert <river_doctor@hotmail.com> wrote:
>Generally, I would like to know how to plot many years of
>annual time series data on the same plot (i.e. from Jan 1 to
>Dec 31 on the x-axis).
>
>I have a column of dates (daily observations -
>1968/01/01...) and a column with the variable Q. I have
>imported the data and have established the vectors (y, m, d,
>Q). I was hoping there was some sort of grouping function I
>could use on y and plot associated values of Q.


I don't understand how you want the plot to appear.

If you want to group y based upon Q, then

sortedvals = sortrows([Q(:),y(:)]);

then sortedvals rows will be [Q,y] pairs with the same values
of Q grouped together.
--
"I was very young in those days, but I was also rather dim."
-- Christopher Priest
Robert

2008-01-30, 8:20 pm

roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson) wrote in
message <fnootg$fnp$1@canopus.cc.umanitoba.ca>...
> In article <fnok6a$aib$1@fred.mathworks.com>,
> Robert <river_doctor@hotmail.com> wrote:
>
> I don't understand how you want the plot to appear.
>
> If you want to group y based upon Q, then
>
> sortedvals = sortrows([Q(:),y(:)]);
>
> then sortedvals rows will be [Q,y] pairs with the same values
> of Q grouped together.
> --
> "I was very young in those days, but I was also rather

dim."
> -- Christopher Priest



Sorry, let me clarify. The data is daily mean discharge
data from a river. So the y axis will be Q and the x axis
days of the year starting Jan 1. I want to plot 30 lines
(hydrographs) on the same plot (one for each year). The
data is in two columns - date and Q and I have used datevec
to separate out y m d. Perhaps it is easier if I
transformed the data so rows=day of year and columns=year so
I would be open to know how to do that easily as well.
Roderick Pearson

2008-01-30, 11:14 pm

"Robert " <river_doctor@hotmail.com> wrote in message
<fnqene$g4r$1@fred.mathworks.com>...
> roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson) wrote in
> message <fnootg$fnp$1@canopus.cc.umanitoba.ca>...
1 to[color=darkred]
m, d,[color=darkred]
function I[color=darkred]
values[color=darkred]
> dim."
>
>
> Sorry, let me clarify. The data is daily mean discharge
> data from a river. So the y axis will be Q and the x axis
> days of the year starting Jan 1. I want to plot 30 lines
> (hydrographs) on the same plot (one for each year). The
> data is in two columns - date and Q and I have used datevec
> to separate out y m d. Perhaps it is easier if I
> transformed the data so rows=day of year and columns=year so
> I would be open to know how to do that easily as well.

Robert you are on the right track. I find it easier to
visualize in my mind when my data is in columns such as
date, Q1,Q2,Q3,.... The real question is what exactly do you
want on the x axis. Do you want the day of year with no
reference to month or season? The most simple way is to
convert the dates to a MATLAB serial date, sort the Q matrix
from lowest to highest date, day one to day 365/366, and
create a column,doy=(1:1:length(yourdatamatrix)) and plot
the q's versus that column of numbers, plot(doy,Q(:,2:end)).
That gets the plot done. You probably will want a more
informative graph but you need to explain how informative
and what toolboxes to which you have access. That will
enable readers to give you more answers
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com