Simple R graph question

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Simple R graph question

ashz
Dear All,

I have several objects (imported from excel via using “xlsx”) with the field names: Month/Year, X, Y1, Y2, Y3.

What is the best library/way to generate a graph which will be consist of multiple plots (Month/Year) that each contain the X, Y1, Y2, Y3 dataset.

Thanks a lot.

Cheers,
Asher


Reply | Threaded
Open this post in threaded view
|

Re: Simple R graph question

jholtman
A little more specificity required; sample of the data, do you want
multiple plots each with a single variable, or do you want them all on
one plot as lines/areas/points/etc.  Do you want then broken down by
year, month, or some other way.  It is easy to generate plots once you
know what you want.  Have you looked at the R-Gallery of plots and is
there one there that you like?

On Fri, Jul 8, 2011 at 4:26 AM, ashz <[hidden email]> wrote:

> Dear All,
>
> I have several objects (imported from excel via using “xlsx”) with the field
> names: Month/Year, X, Y1, Y2, Y3.
>
> What is the best library/way to generate a graph which will be consist of
> multiple plots (Month/Year) that each contain the X, Y1, Y2, Y3 dataset.
>
> Thanks a lot.
>
> Cheers,
> Asher
>
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Simple-R-graph-question-tp3653493p3653493.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



--
Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Simple R graph question

ashz
Dear jholtman,

Thanks for the reply & sorry for the been unclear before.

My desire graph is to have multiply plots showing Y1,Y2,Y3 with the same X,  were each plot is month-year (e.g., 5-2001, 6-2001, etc). It ill be great if each Y can have a different line and point style.
 
The Lattice graphic (http://addictedtor.free.fr/graphiques/graphcode.php?graph=48) looks similar to what I want but the script looks complex for me.

Thanks in advance.
Reply | Threaded
Open this post in threaded view
|

Re: Simple R graph question

Duncan Mackay-2
At 07:12 09/07/2011, you wrote:

>Dear jholtman,
>
>Thanks for the reply & sorry for the been unclear before.
>
>My desire graph is to have multiply plots showing Y1,Y2,Y3 with the same X,
>were each plot is month-year (e.g., 5-2001, 6-2001, etc). It ill be great if
>each Y can have a different line and point style.
>
>The Lattice graphic
>(http://addictedtor.free.fr/graphiques/graphcode.php?graph=48) looks similar
>to what I want but the script looks complex for me.
>
>Thanks in advance.
>
>
>--
>View this message in context:
>http://r.789695.n4.nabble.com/Simple-R-graph-question-tp3653493p3655142.html
>Sent from the R help mailing list archive at Nabble.com.
>
>______________________________________________
>[hidden email] mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

Hi ashz

Try the following simplification which incorporates the par.settings
into xyplot

xyplot(height ~ dist | geology, data = tmp,
        groups = species,
        layout = c(2,2),
        auto.key = list(columns = 2, lines = TRUE),
        par.settings = list(superpose.symbol = list(pch = 1:6, cex = 1.2),
                            superpose.line = list(col = "grey", lty = 1)),
        panel = function(x, y, type, ...) {
          panel.superpose(x, y, type="l", ...)
          panel.superpose(x, y, type="p",...)
        },
)

which can be further simplified to :
xyplot(height ~ dist | geology, data = tmp,
        groups = species,
        layout = c(2,2),
        auto.key = list(columns = 2, lines = TRUE),
        par.settings = list(superpose.symbol = list(pch = 1:6, cex = 1.2),
                            superpose.line = list(col = "grey", lty = 1)),
        panel = function(x, y, type, ...) {
          panel.superpose(x, y, type="b", ...)
        },
)

or an alternative

xyplot(height ~ dist | geology, data = tmp,
        groups = species,
        layout = c(2,2),
        auto.key = list(columns = 2, lines = TRUE),
        par.settings = list(superpose.symbol = list(pch = 1:6, cex = 1.2),
                            superpose.line = list(col = "grey", lty = 1)),
        panel = function(x, y, type, ...) {
          panel.superpose(x, y, type="o", ...)
        },
)

study
?xyplot

Regards

Duncan Mackay

Duncan Mackay
Department of Agronomy and Soil Science
University of New England
ARMIDALE NSW 2351
Email: home [hidden email]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.