Skip to content

Commit 2b6b986

Browse files
committed
Merge pull request #1077 from krlmlr/943-single-color-continuous-scale
Create correct legend for continuous color even if there is only one color
2 parents 4504b99 + 1814643 commit 2b6b986

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
* Create correct legend for continuous color even if there is only one color
2+
(@krlmlr, #943)
3+
14
ggplot2 1.0.1.9000
25
----------------------------------------------------------------
36

R/guide-colorbar.r

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,11 @@ guide_train.colorbar <- function(guide, scale) {
189189
names(guide$key) <- c(output, ".label", ".value")
190190

191191
# bar specification (number of divs etc)
192-
.bar <- discard(pretty(scale_limits(scale), n = guide$nbin), scale_limits(scale))
192+
.limits <- scale_limits(scale)
193+
.bar <- discard(pretty(.limits, n = guide$nbin), scale_limits(scale))
194+
if (length(.bar) == 0) {
195+
.bar = unique(.limits)
196+
}
193197
guide$bar <- data.frame(colour=scale_map(scale, .bar), value=.bar, stringsAsFactors = FALSE)
194198
if (guide$reverse) {
195199
guide$key <- guide$key[nrow(guide$key):1, ]

0 commit comments

Comments
 (0)