[R] Change color of single panel in xyplot

David Winsemius dwinsemius at comcast.net
Fri Nov 20 00:08:52 CET 2009


This was just answered by Deepayan earlier today:

This code did not produce the plot you have linked to. The answer to
your question depends on how you created the plot, so you have to tell
us that. Changing the color in all panels is easy:

histogram(rnorm(100), col = "goldenrod")

Different colors in different panels is a little more work:

histogram(~rnorm(100) | gl(3, 1, 100),
          mycolors = sample(colors(), 3),
          panel = function(..., col, mycolors) {
              panel.histogram(..., col = mycolors[panel.number()])
          })

-Deepayan


--  
David

On Nov 19, 2009, at 5:43 PM, jimdare wrote:

>
> Hi there,
>
> I have created a single page, multi-panel, xyplot using lattice.   
> Each panel
> is a trial (total of 8) from an experiment with 3 variables on the x  
> axis
> and the observed value on the y axis.  I have added the mean of all  
> trials
> so the entire plot looks like this (where M=mean panel and 1-8 = trial
> panels):
>
> M 1 2
> 3 4 5
> 6 7 8
>
> I want to change the colour of the mean panel (M) so that it stands  
> out from
> the trials.  I have tried using: col=c("red",rep("black,8)), but this
> changes the first point to red on all panels.  Is there a way to  
> specify the
> colour for a single panel without changing the rest?
>
> Thanks,
>
> James
>
> -- 
> View this message in context: http://old.nabble.com/Change-color-of-single-panel-in-xyplot-tp26421512p26421512.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org 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.

David Winsemius, MD
Heritage Laboratories
West Hartford, CT




More information about the R-help mailing list