Skip to content

Commit

Permalink
Bug fixing
Browse files Browse the repository at this point in the history
  • Loading branch information
hadley committed Feb 9, 2008
1 parent fc8b17a commit e37c535
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 11 deletions.
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
ggplot 0.6
----------------------------------------

* min and max are now scaled the same way as y
* functions are silently dropped (e.g. aes(colour=col))
* all size measurements (now lines and text as well) are measured in mm, lines/paths default to paths 0.5mm wide
* size legends resize to avoid overlaps
* preliminary legend merging code:
Expand Down
4 changes: 2 additions & 2 deletions R/aaa-compare.r
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Functions for comparing images produced by two different versions of ggplot.

a <- "~/Desktop/test-1/"
b <- "~/Desktop/test-2/"
# a <- "~/Desktop/test-1/"
# b <- "~/Desktop/test-2/"

dir_diff <- function(a, b) {
files_a <- dir(a)
Expand Down
2 changes: 1 addition & 1 deletion R/geom-interval-error.r
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ GeomErrorbar <- proto(GeomInterval, {
}

default_stat <- function(.) StatIdentity
default_aes <- function(.) aes(colour = "black", size=1, linetype=1, width=0.9)
default_aes <- function(.) aes(colour = "black", size=0.5, linetype=1, width=0.9)

seealso <- list(
"geom_pointrange" = "range indicated by straight line, with point in the middle",
Expand Down
1 change: 1 addition & 0 deletions R/geom-interval-histogram.r
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ GeomHistogram <- proto(GeomBar, {
y <- c(0.2, 0.3, 0.5, 0.6,0.2, 0.8, 0.5, 0.3)
rectGrob(seq(0.1, 0.9, by=0.1), y, height=y, width=0.1, vjust=1, gp=gpar(fill="grey60", col=NA))
}
guide_geom <- function(.) "tile"

examples <- function(.) {

Expand Down
3 changes: 2 additions & 1 deletion R/guides-legend.r
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
gglegends <- function(legends, usage) {
# Need to collapse legends describing same values into single data.frame
# - first group by name
if (length(legends) == 0) return()
# if (length(legends) == 0)
return()

names <- unname(unlist(lapply(legends, "[", "name")))
keys <- lapply(legends, "[[", "display")
Expand Down
9 changes: 6 additions & 3 deletions R/layer.r
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ Layer <- proto(expr = {
clone <- function(.) as.proto(.$as.list())

use_defaults <- function(., data) {
# browser()
df <- aesdefaults(data, .$geom$default_aes(), compact(.$aesthetics))
gp <- intersect(names(.$geom$parameters()), names(.$geom_params))
gp <- intersect(names(df), names(.$geom_params))
if (length(.$geom_params[gp]))
gp <- gp[sapply(.$geom_params[gp], is.atomic)]
df[gp] <- .$geom_params[gp]
Expand Down Expand Up @@ -132,7 +133,7 @@ Layer <- proto(expr = {
}

map_statistic <- function(., data, plot) {
if (is.null(data) || nrow(data) == 0) return()
if (is.null(data) || length(data) == 0 || nrow(data) == 0) return()
aesthetics <- defaults(.$aesthetics, defaults(plot$defaults, .$stat$default_aes()))

match <- "\\.\\.([a-zA-z._]+)\\.\\."
Expand Down Expand Up @@ -240,8 +241,10 @@ calc_aesthetics <- function(plot, data = plot$data, aesthetics, ignore.extra = F
cond <- plot$facet$conditionals()

aesthetics <- drop_calculated_aes(aesthetics)
evaled <- eval.each(aesthetics)
evaled <- evaled[sapply(evaled, is.atomic)]

df <- data.frame(eval.each(aesthetics))
df <- data.frame(evaled)
df <- cbind(df, data[,intersect(names(data), cond), drop=FALSE])

if (is.null(plot$data)) return(df)
Expand Down
16 changes: 12 additions & 4 deletions R/scale-.r
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,16 @@ Scale <- proto(TopLevel, expr={
}

transform_df <- function(., df) {
df <- data.frame(.$stransform(df[, .$input()]))
input <- .$input()
output <- .$output()
transform <- function(var) .$stransform(df[, var])

if (length(input) == 1 && input == "y") {
input <- output <- intersect(c("y","min", "max"), names(df))
}
df <- do.call("data.frame", lapply(input, transform))
if (ncol(df) == 0) return(NULL)
names(df) <- .$output()
names(df) <- output
df
}

Expand Down Expand Up @@ -116,11 +123,12 @@ Scale <- proto(TopLevel, expr={
if (identical(., Scale) || !.$legend) return()

breaks <- .$rbreaks()
if (is.null(breaks)) return()
labels <- .$labels()
if (is.null(breaks) || is.null(labels)) return()

df <- data.frame(breaks, stringsAsFactors = FALSE)
names(df) <- .$output()
df$label <- .$labels()
df$label <- labels
list(
name = .$name,
aesthetic = .$output(),
Expand Down

0 comments on commit e37c535

Please sign in to comment.