[BioC] hexbin, par("usr"), legend

Nicholas Lewin-Koh nikko at hailmail.net
Fri Oct 22 12:00:59 CEST 2004


Hi Jenny,
Just to add to what Martin said; We are working on making 
hexbin much more flexible. The price for the flexibility is using grid,
which isn't bad one you get used to it. Under the new model
you can simply do something like
> x<-rnorm(10000)
> y<-rnorm(10000)
> hbin<-hexbin(x,y)
> hp<-hexViewport(hbin,offset=unit(1.2,"inches"),mar=NULL,newpage=TRUE)
> pushViewport(hp)
> grid.rect()
> grid.xaxis()
> grid.yaxis()
> hexagons(hbin,style="centroid")
> hloess<-loess(y~x,data=hcell2xy(hbin),hbin at count)
> grid.lines(seq(-4,4,by=.2),predict(hloess,seq(-4,4,by=.2)),gp=gpar(col='red'),default.units="native")
> popViewport()
etc ....

This example would have been a royal pain in the old version, because of
having to
manipulate pars and still may not have worked.
This should allow very flexible construction of plots, for instance all 
the different plot types in hexbin are now created using hexViewport.

Hope this will be useful

Nicholas

On Thu, 21 Oct 2004 22:28:43 +0200, "Martin Maechler"
<maechler at stat.math.ethz.ch> said:
> >>>>> "Jenny" == Jenny Bryan <jenny at stat.ubc.ca>
> >>>>>     on Thu, 21 Oct 2004 10:17:19 -0700 writes:
> 
>     Jenny> Are there any plans for changing the behavior of
>     Jenny> "plot.hexbin" w.r.t. the graphics parameters,
>     Jenny> especially 'par("usr")'?  The current behavior makes
>     Jenny> it hard to add elements to the plot (which is a
>     Jenny> really handy and attractive plot, I should add).  I
>     Jenny> know I can create a type="n" plot of the x-range and
>     Jenny> y-range, use 'hexagons' to add the hexagons, and add
>     Jenny> other elements to my heart's content .... but then
>     Jenny> the legend for the hexagon colorramp becomes a
>     Jenny> difficulty (the documentation is clear that the
>     Jenny> legend function is not really meant to be called by a
>     Jenny> user, but only by "plot.hexbin").
> 
> yes, there are big plans for big changes:
> 
> The current development version of hexbin will use  grid
> graphics which allows "everything" in principle,
> but the user utility functions might well be lacking initially
> -- and you willl have t ouse grid (or lattice) graphics;
> no par(.), no traditional graphics...
> Also, the result of hexbin() will be an S4 object instead of a list.
> 
> There is some unfinished discussion going on, 
> if the old version of hexbin should be kept available in package
> "hexbin0" -- for those of you who can't update quickly to the
> new API to hexbin graphics.
> 
> 
> 
> 
>     Jenny> Thanks, Jenny
> 
>     Jenny> -- Jenny Bryan, Ph.D.
>     Jenny> *----------------------------------* * Assistant
>     Jenny> Professor * * Department of Statistics and * * the
>     Jenny> Michael Smith Laboratories * * University of British
>     Jenny> Columbia * *----------------------------------*
>     Jenny> 333-6356 Agricultural Road Vancouver, BC V6T 1Z2
>     Jenny> Canada http://hajek.stat.ubc.ca/~jenny/ tel:
>     Jenny> 604.822.6422 fax: 604.822.6960 email:
>     Jenny> jenny at stat.ubc.ca
> 
>     Jenny> _______________________________________________
>     Jenny> Bioconductor mailing list
>     Jenny> Bioconductor at stat.math.ethz.ch
>     Jenny> https://stat.ethz.ch/mailman/listinfo/bioconductor



More information about the Bioconductor mailing list