--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: http://gist.github.com/270442
To post: email ggp...@googlegroups.com
To unsubscribe: email ggplot2+u...@googlegroups.com
More options: http://groups.google.com/group/ggplot2
The basic problem is that tiles are sized in data coordinates, and
points are sized in absolute units. There's basically no way to unify
them (except to draw polygon circles in data space).
Hadley
--
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/
several weeks ago I wrote a geom-circle function for my own purpose,
but probably it is relevant to what you want.
here is an example code. maybe you can find your solution.
GeomCircle <- proto(Geom, {
default_stat <- function(.) StatIdentity
default_pos <- function(.) PositionIdentity
default_aes <- function(.) aes(colour=NA, fill="grey20", radius=0.5,
linetype=1, alpha = 1)
required_aes <- c("x", "y")
draw <- draw_groups <- function(., data, scales, coordinates, ...) {
data <- remove_missing(data, na.rm,
c("x", "y", "radius"), name = "geom_circle")
if (empty(data)) return(zeroGrob())
with(coordinates$transform(data, scales),
ggname(.$my_name(), circleGrob(x, y, r = radius, default.unit = "native",
gp=gpar(col=alpha(colour, alpha), fill = alpha(fill, alpha))))
)
}
objname <- "circle"
guide_geom <- function(.) "polygon"
})
geom_circle <- GeomCircle$build_accessor()
d1 <- as.Date("2009-10-01")
d2 <- as.Date("2009-10-15")
xd <- rep( seq(d1,d2,by="day"), each=15 )
yd <- rep( seq(d1,d2,by="day"), 15 )
mm <- data.frame( xd=xd, yd=yd )
mm$mean <- runif( nrow(mm), min=1, max=2 )
mm$max <- runif( nrow(mm), min=2, max=3 )
mm$count <- floor( runif( nrow(mm), min=-24, max=24 ) )
mm <- transform(mm, smean = mean/base::max(max), smax = max/base::max(max))
radius <- 1/2/max(length(unique(mm$xd)), length(unique(mm$yd)))
p <- ggplot( mm, aes( x=xd, y=yd ) ) +
geom_tile( aes(fill=count), colour="black", space="Lab" ) +
geom_circle(aes(radius=radius*smax), alpha=0.4) +
geom_circle(aes(radius=radius*smean), fill="white", colour="white") +
scale_fill_gradient2( limits=c( -24, 24 ),
name="high/low\ncount",
low="darkgreen",
mid="yellow",
high="darkred") +
scale_size( name="Maximum\nand mean\ndifference\nin hourly\nmean" )
mm2 <- subset(mm, xd < 14523 & yd < 14522)
radius <- 1/2/max(length(unique(mm2$xd)), length(unique(mm2$yd)))
p <- ggplot( mm2, aes( x=xd, y=yd ) ) +
geom_tile( aes(fill=count), colour="black", space="Lab" ) +
geom_circle(aes(radius=radius*smax), alpha=0.4) +
geom_circle(aes(radius=radius*smean), fill="white", colour="white") +
scale_fill_gradient2( limits=c( -24, 24 ),
name="high/low\ncount",
low="darkgreen",
mid="yellow",
high="darkred") +
scale_size( name="Maximum\nand mean\ndifference\nin hourly\nmean" )
--
Kohske Takahashi <takahash...@gmail.com>
Research Center for Advanced Science and Technology,
The University of Tokyo, Japan.
http://www.fennel.rcast.u-tokyo.ac.jp/profilee_ktakahashi.html