Skip to content

Commit

Permalink
Ensure labels work in all continuous colour gradients
Browse files Browse the repository at this point in the history
  • Loading branch information
hadley committed Dec 7, 2009
1 parent 6ba226c commit 5fc99a8
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 12 deletions.
28 changes: 18 additions & 10 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,27 +1,35 @@
ggplot2 0.8.4 (2009-XX-XX)
----------------------------------------
ggplot2 0.8.4 (2009-XX-XX) ----------------------------------------

* aes and aes_string both convert prefixes to full names
* aesthetics: corrected list of aesthetics to include american spelling of colour as well as base R abbreviations
* aesthetics: corrected list of aesthetics to include american spelling of
colour as well as base R abbreviations
* aesthetics: fix bug in detecting which aesthetics are calculated
* aes_string treats NULL as "NULL"
* annotate now works with missing x and y (e.g. for geom_rect)
* continuous scale limits now automatically sorted
* coord_polar: fix bug if breaks not all inside limits
* facet_wrap: can now specify both ncol and nrow without getting an error
* facet_wrap: now works with statistics that produce both x and y values (e.g. stat_qq)
* fullseq now adds additional break on bottom if necessary, so that the include.lowest argument in cut never comes into play (this the source of a potential bug in histograms)
* facet_wrap: now works with statistics that produce both x and y values (e.g.
stat_qq)
* fullseq now adds additional break on bottom if necessary, so that the
include.lowest argument in cut never comes into play (this the source of a
potential bug in histograms)
* geom_boxplot: alpha now affects fill colour of boxes only
* geom_path correctly switches to segments if varying alpha used (thanks to Karl Ove Hufthammer for the report and Baptiste Auguie for the fix)
* geom_path correctly switches to segments if varying alpha used (thanks to
Karl Ove Hufthammer for the report and Baptiste Auguie for the fix)
* geom_point: the alpha aesthetic now also affects the fill.
* geom_ribbon always sorts input to avoid problems with certain pathological inputs
* geom_ribbon always sorts input to avoid problems with certain pathological
inputs
* geom_smooth was incorrectly applying alpha to line colour in the legend
* nullGrob renamed to zeroGrob to avoid name conflict with grid
* position_collide now works with missing values
* position_stack: fixed bug in detection of overlap for negative values
* scale_discrete_position now uses drop argument to force dropping of unused levels
* scale_gradient now uses labels parameters, if supplied
* scale_discrete_position now uses drop argument to force dropping of unused
levels
* scale_gradient, scale_gradient2 and scale_gradientn now uses label
parameters, if supplied
* scale_x_inverse, scale_y_inverse now actually work, and added recip as alias
* stat_qq now correctly groups results
* stat_smooth will not try and fit a line to 2 or fewer points (previously didn't try for only 1 point)
* stat_smooth will not try and fit a line to 2 or fewer points (previously
didn't try for only 1 point)
* stat_spoke now works with reversed scales
12 changes: 10 additions & 2 deletions R/scale-continuous-colour.r
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ ScaleGradient2 <- proto(ScaleContinuous, expr={
desc <- "Smooth gradient between three colours (high, low and midpoints)"

output_breaks <- function(.) .$map(.$input_breaks())
labels <- function(.) .$.tr$label(.$input_breaks())
labels <- function(.) {
nulldefault(.$.labels, .$.tr$label(.$input_breaks()))
}

icon <- function(.) {
g <- scale_fill_gradient2()
Expand Down Expand Up @@ -215,7 +217,9 @@ ScaleGradientn <- proto(ScaleContinuous, expr={
desc <- "Smooth gradient between n colours"

output_breaks <- function(.) .$map(.$input_breaks())
labels <- function(.) .$.tr$label(.$input_breaks())
labels <- function(.) {
nulldefault(.$.labels, .$.tr$label(.$input_breaks()))
}

icon <- function(.) {
g <- scale_fill_gradientn(colours = rainbow(7))
Expand All @@ -242,6 +246,10 @@ ScaleGradientn <- proto(ScaleContinuous, expr={
(d <- qplot(x, y, data=dsub, colour=diff))

d + scale_colour_gradientn(colour = rainbow(7))
breaks <- c(-0.5, 0, 0.5)
d + scale_colour_gradientn(colour = rainbow(7),
breaks = breaks, labels = format(breaks))

d + scale_colour_gradientn(colour = topo.colors(10))
d + scale_colour_gradientn(colour = terrain.colors(10))

Expand Down

0 comments on commit 5fc99a8

Please sign in to comment.