Skip to content

Commit

Permalink
Ensure all geom pass scales to coordinates transform etc
Browse files Browse the repository at this point in the history
  • Loading branch information
hadley committed Oct 10, 2008
1 parent 2f1fcb1 commit 926fb38
Show file tree
Hide file tree
Showing 9 changed files with 9 additions and 11 deletions.
2 changes: 1 addition & 1 deletion R/geom-hex.r
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ GeomHexbin <- proto(Geom, {
# c(diff(scales$get_scales("x")$output_set()),
# diff(scales$get_scales("y")$output_set()))

with(coordinates$transform(data),
with(coordinates$transform(data, scales),
ggname(.$my_name(), hexGrob(x, y, binwidth, col=colour, fill = fill))
)
}
Expand Down
3 changes: 1 addition & 2 deletions R/geom-linerange.r
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ GeomLinerange <- proto(Geom, {
required_aes <- c("x", "ymin", "ymax")

draw <- function(., data, scales, coordinates, ...) {
munched <- coordinates$transform(data)

munched <- coordinates$transform(data, scales)
ggname(.$my_name(), GeomSegment$draw(transform(data, xend=x, y=ymin, yend=ymax), scales, coordinates, ...))
}

Expand Down
2 changes: 1 addition & 1 deletion R/geom-path-.r
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ GeomPath <- proto(Geom, {
draw <- function(., data, scales, coordinates, ...) {
if (nrow(data) < 2) return()

munched <- coordinates$munch(data)
munched <- coordinates$munch(data, scales)

# Work out whether we should use lines or segments
g <- split(munched, munched$group)
Expand Down
2 changes: 1 addition & 1 deletion R/geom-polygon.r
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ GeomPolygon <- proto(Geom, {
if (n == 1) return()

ggname(.$my_name(), gTree(children=gList(
with(coordinates$munch(data),
with(coordinates$munch(data, scales),
polygonGrob(x, y, default.units="native",
gp=gpar(col=colour, fill=fill, lwd=size * .pt, linetype=linetype))
)
Expand Down
2 changes: 1 addition & 1 deletion R/geom-rect.r
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ GeomRect <- proto(Geom, {

ggname("bar",do.call("grobTree", polys))
} else {
with(coordinates$transform(data),
with(coordinates$transform(data, scales),
ggname(.$my_name(), rectGrob(
xmin, ymax,
width = xmax - xmin, height = ymax - ymin,
Expand Down
2 changes: 1 addition & 1 deletion R/geom-ribbon-.r
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ GeomRibbon <- proto(Geom, {
draw <- function(., data, scales, coordinates, ...) {
data <- data[complete.cases(data[, c("x","ymin","ymax")]), ]
tb <- with(data,
coordinates$munch(data.frame(x=c(x, rev(x)), y=c(ymax, rev(ymin))))
coordinates$munch(data.frame(x=c(x, rev(x)), y=c(ymax, rev(ymin))), scales)
)

with(data, ggname(.$my_name(), gTree(children=gList(
Expand Down
3 changes: 1 addition & 2 deletions R/geom-rug.r
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
GeomRug <- proto(Geom, {
draw <- function(., data, scales, coordinates, ...) {
rugs <- list()
data <- coordinates$transform(data)

data <- coordinates$transform(data, scales)
if (!is.null(data$x)) {
rugs$x <- with(data, segmentsGrob(
x0 = unit(x, "native"), x1 = unit(x, "native"),
Expand Down
2 changes: 1 addition & 1 deletion R/geom-segment.r
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
GeomSegment <- proto(Geom, {
draw <- function(., data, scales, coordinates, arrow=NULL, ...) {
if (!coordinates$muncher()) {
return(with(coordinates$transform(data),
return(with(coordinates$transform(data, scales),
segmentsGrob(x, y, xend, yend, default.units="native",
gp=gpar(col=colour, lwd=size * .pt, lty=linetype), arrow = arrow)
))
Expand Down
2 changes: 1 addition & 1 deletion R/geom-text.r
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
GeomText <- proto(Geom, {
draw <- function(., data, scales, coordinates, ...) {
with(coordinates$transform(data),
with(coordinates$transform(data, scales),
textGrob(label, x, y, default.units="native", hjust=hjust, vjust=vjust, rot=angle,
gp=gpar(col=colour, fontsize=size * .pt))
)
Expand Down

0 comments on commit 926fb38

Please sign in to comment.