plot.hexbin {hexbin} | R Documentation |
Plots the counts in an hexbin object using 5 different styles. Provides a legend indicating the count representations.
plot.hexbin(x, style = "colorscale", legend = 1, lcex = 1, minarea = 0.04, maxarea = 0.8, mincnt = 1, maxcnt = max(bin$cnt), trans = NULL, inv = NULL, colorcut = seq(0, 1, length = min(17, maxcnt)), border = FALSE, density = NULL, pen = NULL, colramp = function(n){ LinGray(n,beg = 90,end = 15) }, xlab = "", ylab = "", verbose = getOption("verbose"), ...)
x |
an object of type hexbin. |
style |
string, one of ("colorscale", "lattice", "centroids",
"nested.lattice", "nested.centroids") , see hexagons . |
legend |
width of the legend in inches. If False or 0 the legend is not produced. |
lcex |
characters expansion size for the text in the legend |
minarea |
fraction of cell area for the lowest count |
maxarea |
fraction of the cell area for the largest count |
mincnt |
cells with fewer counts are ignored. |
maxcnt |
cells with more counts are ignored. |
trans |
function specifying a transformation for
the counts such as sqrt . |
inv |
the inverse transformation of trans . |
colorcut |
vector of values covering [0, 1] that determine hexagon color class boundaries and hexagon legend size boundaries. |
border |
Polygon() border argument. Draw the border for each hexagon |
density |
Polygon() fill argument. 0 causes the polygon not to be filled. |
pen |
Polygon() col argument. Determines the color with which the polygon will be filled |
colramp |
function accepting an integer n as an argument and
returning n colors. |
xlab |
xlabel argument to plot(). |
ylab |
ylabel argument to plot(). |
verbose |
logical indicating if some diagnostic output should happen. |
... |
additional arguments from and passed to plot methods. |
The legend function is preliminary. Later version will include refinements and handle extreme cases (small and large) for cell size and counts.
For style
, minarea
etc, see the Details section of
hexagons
's help page.
Graphics parameters
This function determines the plot shape, so hexagons appear as hexagons. The process alters graphics parameters. The parameters are reset to that before the function call when the function exits. The function returns the parameters for plotting the hexagons invisibly. Users can store the parameters and reinvoke them to add to the plot. See the third example below.
invisible(par)
Dan Carr <dcarr@voxel.galaxy.gmu.edu> ported by Nicholas Lewin-Koh <kohnicho@comp.nus.edu.sg>
see in hexagons
.
hexbin
, smooth.hexbin
, erode.hexbin
,
hcell
, hcell2xy
,
hboxplot
, hdiffplot
,
hmatplot
.
# simple binning x <- rnorm(10000) y <- rnorm(10000) bin <- hexbin(x,y) # basic plot plot(bin) # nested lattice plot(bin, style= "nested.lattice") # controlling the colorscheme plot(bin,colramp=BTY,colorcut=c(0,.1,.2,.3,.4,.6,1)) # A mixture distribution x <- c(rnorm(5000),rnorm(5000,4,1.5)) y <- c(rnorm(5000),rnorm(5000,2,3)) bin <- hexbin(x,y) pens<-c("#ECE2F0","#A6BDDB","#1C9099","#FFF7BC","#FEC44F","#D95F0E") pens<-matrix(pens,3,2) plot(bin, style = "nested.lattice",pen=pens) # now really crazy plot(bin, style = "nested.lattice",pen=pens,border=2,density=35) # lower resolution binning and overplotting with counts oldpar <- par(no.readonly=TRUE) bin <- hexbin(x,y,xbins=25) scrPar <- plot.hexbin(bin, style= "lattice",legend=FALSE, minarea=1,maxarea=1,border="white") par(scrPar) # reset graphics to the plot on the screen xy <- hcell2xy(bin) text(xy$x,xy$y,as.character(bin$cnt),adj=.5,cex=.3,col="red") points(x,y,pch=18,col="red") # to show points rather than counts par(oldpar) # reset graphics # Be creative, have fun!