hextri (version 0.6)

panel.hextri: A lattice panel function for hexagonal binning with classes

Description

Displays a hexagonally-binned scatterplot with coloured subtriangles to indicate number of observations in each class. Uses the Sainte-Lague method to apportion counts to triangles, ensuring the counts round to exactly six triangles per hexagon.

Usage

panel.hextri(x, y, groups, subscripts, colours, nbins = 10, border = TRUE,
   diffuse = FALSE, style = c("alpha", "size"), weights = NULL,
   sorted=!diffuse, shape = 1, ...)

Arguments

x,y

point coordinates for the subset being plotted

groups

A factor giving the class identity for all points (will be filled in automatically by xyplot)

subscripts

Vector selecting the elements of groups that are in the panel (will be filled in automatically by xyplot)

colours

Vector of colors (number, name, or hashtag format) giving the colours for each class

nbins

Number of bins along the x axis

border

If TRUE, leave a transparent border around each element drawn

diffuse

If TRUE pass on rounding error to nearest not-yet-drawn hexes so that rare classes get represented

style

Represent data by hexagon size or by alpha-blending

weights

If not NULL, sampling weights or frequency weights. The hexbin plot will be based on the sum of weights in the hex

sorted

Sort the triangles into a consistent order within each hex?

shape

Aspect ratio for each hex.

because you have to.

Value

A panel

See Also

hextri is the base-graphics plot

Examples

Run this code
# NOT RUN {
library(lattice)
xx<-rnorm(1000)
yy<-rnorm(1000)
cc<-cut(xx*yy,c(-Inf,-.4,0,.4,Inf))
zz<-cut(xx+yy,c(-Inf,-1,0,1,Inf))

plot(xx,yy,col=(1:4)[cc])
xyplot(yy~xx|zz, panel=panel.hextri,groups=cc,colours=1:4,style="size",nbins=10)

data(airquality)
airquality$o3group<-with(airquality, cut(Ozone, c(0,18,60,Inf)))

xyplot(Temp~Solar.R|equal.count(Wind,4), groups=o3group, panel=panel.hextri,
  data=na.omit(airquality),colours=c("royalblue","grey60","goldenrod"),
  strip=strip.custom(var.name="Wind Speed"),xlab="Solar Radiation (langley)",
  ylab="Temperature (F)")
# }

Run the code above in your browser using DataLab