Questions tagged [lattice]

lattice is a package that forms part of base R and allows the creation of trellis-type graphics.

R's lattice package, developed by Deepayan Sarkar, is a port of Bell Laboratories' Trellis Graphics to R. It is one of the three main graphics options in R, the other two being R's base graphics capabilities and .

Repositories

Vignettes

Books

Other resources

R packages extending lattice

  • latticeDensity: Density estimation and nonparametric regression on irregular regions.
  • latticeExtra: Extra Graphical Utilities Based on Lattice.
  • latticist: A graphical user interface for exploratory visualisation.
  • latticedl: Lattice direct labels, for automatically labeling points.

Related tags

1251 questions
0
votes
1 answer

Automatically scale x-axis by date range within a factor using xyplot()

I've been trying to write out an R script that will plot the date-temp series for a set of locations that are identified by a Deployment_ID. Ideally, each page of the output pdf would have the name of the Deployment_ID (check), a graph with proper…
0
votes
1 answer

Make panels fill screen in lattice?

I am plotting out some grouped data from nlme and I have 120 panels. The default plotting plot(dataG) puts them in 2 rows, 60 columns, which fills up the screen, but is too difficult to read. When I specify the layout plot(dataG), layout=…
Nazer
  • 3,654
  • 8
  • 33
  • 47
0
votes
0 answers

sweave; figure not portable

I'm a newbie to sweave and latex and I have a problem importing a plot figure in Latex. I used the xyplot() from the lattice package. I did include print() in the code, but when I sweave, there is warning in R, saying "file name 'xxxx' is not…
charlotte
  • 107
  • 1
  • 1
  • 11
0
votes
1 answer

align 0 in the same line in lattice (2)

I have asked a similar question where I could use stack=T to solve my problem. However, when I introduce another factor, stack=T is not working. Please see this example: test <- data.frame(a=c(rep('x', 4),rep('y',4)), …
user36102
  • 275
  • 2
  • 3
  • 12
0
votes
1 answer

align 0 in the same line in lattice

This is the code for ggplot2 library(ggplot2) test <- data.frame(a=c('1','1','2','2'),b=c(2,-2,4,-3),d=c('m','n','m','n')) p <- ggplot(test,aes(a,b)) p + geom_bar(position=position_dodge(),stat='identity', …
user36102
  • 275
  • 2
  • 3
  • 12
0
votes
0 answers

Adding different vertical lines for each panel in xyplot using lattice in R

I have a graph of plant species frequency by year for several sites that I am plotting using xyplot in the lattice package. I've figured out how to get the scatterplot for each species-site combo. However, I want to add an abline representing each…
0
votes
1 answer

margin coordinates of grid graphics in R

I'm about to create a hexbin (lattice) plot that includes vertical lines and margin text. The margin text of the MWE should be located above the line and it should simply state the x-value of the line. Here's what I've got so far: library(hexbin) …
AnjaM
  • 2,941
  • 8
  • 39
  • 62
0
votes
1 answer

Tiled xyplots, how to colour independently to mimic levelplot map?

I am trying to plot several lines using the lattice package to produce a tiled figure. Here is an example (which is wrong, see bellow): (source: ubuntuone.com) I would like to mimic this one (in terms of the colour pattern) : (source:…
lourencoj
  • 362
  • 4
  • 16
0
votes
1 answer

calling levelplot from a function

Very weird behavior using levelplot inside a function: > foo <- function() { require(lattice); levelplot(matrix(rnorm(100),10,10)) } > bar <- function() { require(lattice); levelplot(matrix(rnorm(100),10,10)); return(1) } > foo() ## graph gets…
user2623214
  • 133
  • 4
0
votes
2 answers

bwplot axis values are displayed incorrectly

the following code produces a bwplot, but the values on the y axis are 1,2,3,4,5 instead of 10,11,12,13,14. How can I correct this? library(lattice) test <- data.frame(c(rep(10,100),rep(11,100),rep(12,100),rep(13,100),rep(14,100)) …
Tania
  • 285
  • 1
  • 4
  • 13
0
votes
1 answer

Exporting a levelplot to a png file while keeping the ratio of axes

As a follow-up on Adding a background image to a levelplot I'm exporting the levelplot to a png file, and I'd like to know how I can access the width and height of that trellis object to pass it as parameters to…
Roland
  • 517
  • 8
  • 25
0
votes
1 answer

Plot value outside its parameters

Sample data/example: x <- log(seq(1,11,1)) y <- seq(0,1,0.1) plot <- xyplot(y~x, type="l") update(plot, panel = function(...) { panel.xyplot(...)})+as.layer(xyplot(y[3]~x[3], type=c("p"), lwd=3, cex=3, pch=3)) Now, lets say that I have a new…
Maximilian
  • 4,177
  • 7
  • 46
  • 85
0
votes
1 answer

Use 2 grouping variables in a 3D lattice plot in R

I'm trying to produce a 3D cloud plot using the lattice package in R. I'd like colors and symbols to be grouped by two different factors on the plot. I found this example of how to do this using xyplot, but i'm having trouble adapting it for the…
Chris
  • 401
  • 1
  • 5
  • 10
0
votes
1 answer

Adding a background image to a levelplot

I'd like to make a levelplot which has a background image. The following code promts the error message Error in rasterImage(image, x[1], y[1], x[length(x)], y[length(y)]) : plot.new has not been called yet - apparently rasterImage does not…
Roland
  • 517
  • 8
  • 25
0
votes
0 answers

How to plot several violin plots in one panel as a function of time in R using lattice?

Here's a minimal example of my data and the plot I was able to adapt from this tutorial: require(lattice) t <- c(0.88,3.52,7.04,10.56,18.48,29.92,29.6,52.8,70.4) n <- 1000 mu.A <-…
Gerome Bochmann
  • 496
  • 6
  • 19