[R] Grid Points
Gabor Grothendieck
ggrothendieck at gmail.com
Sun Aug 20 15:28:30 CEST 2006
Try this. gl(2,50) is such that the first 50 points are series 1
and the second 50 points are series 2. The scales= argument
defines the positions of the tick marks and the xlim= argument
defines the x axis limits. The layout puts the panels on top
of each other rather than side by side. strip = FALSE eliminates
the strip above each panel. type= says we want lines. The
panel function puts points at the grid locations in each panel
and then calls xyplot to plot the lines.
library(lattice)
library(grid)
x <- 601:700
at <- seq(500, 800, 50)
xyplot(x ~ x | gl(2, 50), scales = list(at = at), xlim = c(500, 700),
layout = 1:2, strip = FALSE, type = "l",
panel = function(...) {
grid.points(at, unit(rep(.01, length(at)), "npc"),
pch = 20, size = unit(.2, "char"))
panel.xyplot(...)
})
On 8/20/06, Anupam Tyagi <AnupTyagi at yahoo.com> wrote:
> How do I put grid points (not grid lines) as the base layer of an xyplot?
>
> Is there a way to vary the interval at which x and y grid points are placed?
>
> Is it possible to start a graph so that Y axis begins at 500 and ends at 800? I
> am only interested in focusing on the relative distance between the points whose
> values are between 500 and 800, but not their relative distance from zero.
>
> Is there a way in R to draw two graphs so that that "share" the same X axis, but
> without the gap that mfrow() creates? The origin of the top graph should be
> where the Y-axis of the bottom graph ends. It will be useful for what I am
> trying to do to have the X axis of the top graph be invisible.
>
> Anupam.
>
> ______________________________________________
> R-help at stat.math.ethz.ch 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.
>
More information about the R-help
mailing list