@@ -234,6 +234,23 @@ to_basic.GeomTile <- function(data, prestats_data, layout, params, ...) {
234234 }
235235}
236236
237+ # ' @export
238+ to_basic.GeomHex <- function (data , prestats_data , layout , params , ... ) {
239+ # see ggplot2:::hexGrob
240+ dx <- resolution(data $ x , FALSE )
241+ dy <- resolution(data $ y , FALSE )/ sqrt(3 )/ 2 * 1.15
242+ hexC <- hexbin :: hexcoords(dx , dy , n = 1 )
243+ n <- nrow(data )
244+ data $ size <- ifelse(data $ size < 1 , data $ size ^ (1 / 6 ), data $ size ^ 2 )
245+ x <- rep.int(hexC $ x , n ) * rep(data $ size , each = 6 ) + rep(data $ x , each = 6 )
246+ y <- rep.int(hexC $ y , n ) * rep(data $ size , each = 6 ) + rep(data $ y , each = 6 )
247+ data <- data [rep(seq_len(n ), each = 6 ), ]
248+ data $ x <- x
249+ data $ y <- y
250+ data $ group <- rep(seq_len(n ), each = 6 )
251+ prefix_class(data , c(" GeomPolygon" , " GeomHex" ))
252+ }
253+
237254# ' @export
238255to_basic.GeomContour <- function (data , prestats_data , layout , params , ... ) {
239256 if (! " fill" %in% names(data )) data $ fill <- NA
@@ -291,6 +308,7 @@ to_basic.GeomJitter <- function(data, prestats_data, layout, params, ...) {
291308 prefix_class(data , " GeomPoint" )
292309}
293310
311+
294312# ' @export
295313to_basic.GeomErrorbar <- function (data , prestats_data , layout , params , ... ) {
296314 # width for ggplot2 means size of the entire bar, on the data scale
0 commit comments