Hallo, I'd like to add grid lines to a lattice graph having 2 series of Y data. See these 2 examples: data(iris) [1] xyplot(Sepal.Length + Sepal.Width ~ Petal.Length , data = iris, allow.multiple = TRUE, scales = "same",type="l", ) [2] xyplot(Sepal.Length + Sepal.Width ~ Petal.Length , data = iris, allow.multiple = TRUE, scales = "same",type="l", panel = function(x, y) { panel.grid(h=2, v= 3) panel.xyplot(x, y) } ) Question: is it possible to keep all the formats of example [1] (colors, type="l", ...), and just add the grids appearing in example 2. Moreover I'd like to choose the color of the grid... Thanks for you help, Marc Mamin
On Tuesday 09 September 2003 04:49, Marc Mamin wrote:> Hallo, > > I'd like to add grid lines to a lattice graph having 2 series of Y data. > > See these 2 examples: > > > > data(iris) > > [1] > xyplot(Sepal.Length + Sepal.Width ~ Petal.Length , > data = iris, allow.multiple = TRUE, scales = "same",type="l", > ) > > > [2] > xyplot(Sepal.Length + Sepal.Width ~ Petal.Length , > data = iris, allow.multiple = TRUE, scales = "same",type="l", > panel = function(x, y) { > panel.grid(h=2, v= 3) > panel.xyplot(x, y) > } > ) > > > Question: is it possible to keep all the formats of example [1] (colors, > type="l", ...), and just add the grids appearing in example 2. > Moreover I'd like to choose the color of the grid...Something like this should work: xyplot(Sepal.Length + Sepal.Width ~ Petal.Length , data = iris, allow.multiple = TRUE, scales = "same",type="l", panel = function(...) { panel.grid(h=2, v= 3, col="blue") panel.xyplot(...) } ) Deepayan
Hallo, thank you for your answer, there is still one problem in your solution: Sepal.Length + Sepal.Width are considerd as a single serie of data... Marc Mamin -----Original Message----- From: Deepayan Sarkar [mailto:deepayan at stat.wisc.edu] Sent: Tuesday, September 09, 2003 3:03 PM To: Marc Mamin; R-help Subject: Re: [R] lattice.xyplot: adding grid lines On Tuesday 09 September 2003 04:49, Marc Mamin wrote:> Hallo, > > I'd like to add grid lines to a lattice graph having 2 series of Y data. > > See these 2 examples: > > > > data(iris) > > [1] > xyplot(Sepal.Length + Sepal.Width ~ Petal.Length , > data = iris, allow.multiple = TRUE, scales = "same",type="l", > ) > > > [2] > xyplot(Sepal.Length + Sepal.Width ~ Petal.Length , > data = iris, allow.multiple = TRUE, scales = "same",type="l", > panel = function(x, y) { > panel.grid(h=2, v= 3) > panel.xyplot(x, y) > } > ) > > > Question: is it possible to keep all the formats of example [1] (colors, > type="l", ...), and just add the grids appearing in example 2. > Moreover I'd like to choose the color of the grid...Something like this should work: xyplot(Sepal.Length + Sepal.Width ~ Petal.Length , data = iris, allow.multiple = TRUE, scales = "same",type="l", panel = function(...) { panel.grid(h=2, v= 3, col="blue") panel.xyplot(...) } ) Deepayan
Seemingly Similar Threads
- trellis.par.set and grid : how to set by default that I want a grid on my graphes ?
- a problem 'cor' function
- xyplot: Combining 'subscripts' and 'allow.multiple=T'
- split data, but ensure each level of the factor is represented
- multiple plots per page using hist and pdf