You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, I'm using a more polished version of this for a print document, and would like to add direct labels, one per group and with colors matching the fill of the waffle squares. I've done that by pulling out coordinates with ggplot_build and then adding a geom_text layer to the waffle plot. But when I add something with a color aesthetic—here via some dummy text—an additional level "white" gets added to the factor that makes the colors, and their levels get reset back to alphabetical order. One attempt setting color = "white" manually, which still sets the border color properly but then adds this phantom level that shows up in the legend:
Oddly, even with falling back on the default color argument (or setting it to any other color), this level still shows up:
# still has white factor level
ggplot(race) +
geom_waffle(aes(fill=group, values=share), flip=TRUE) +
geom_text(aes(x=5, y=5, label="dummy text", color=group))
I'm guessing something gets confused with having color arguments come from multiple places (or multiple spellings?). Here's the calculated data:
head(ggplot_build(p_race)$data[[1]])
#> fill colour y x values PANEL group xmin xmax ymin ymax alpha size#> 1 #F8766D white 1 1 NA 1 1 0.5 1.5 0.5 1.5 NA 0.125#> 2 #F8766D white 1 2 NA 1 2 1.5 2.5 0.5 1.5 NA 0.125#> 3 #F8766D white 1 3 NA 1 3 2.5 3.5 0.5 1.5 NA 0.125#> 4 #F8766D white 1 4 NA 1 4 3.5 4.5 0.5 1.5 NA 0.125#> 5 #F8766D white 1 5 NA 1 5 4.5 5.5 0.5 1.5 NA 0.125#> 6 #F8766D white 1 6 NA 1 6 5.5 6.5 0.5 1.5 NA 0.125#> linetype width height#> 1 1 NA NA#> 2 1 NA NA#> 3 1 NA NA#> 4 1 NA NA#> 5 1 NA NA#> 6 1 NA NA
Obviously I can work around this: using a named vector for colors with a dummy white = NA, or pulling the calculated data out and rebuilding the waffle squares myself. But I wanted to see if there is in fact a bug, or if I'm just trying to make it do too much.
First off, really appreciate this package and the thought that obviously went into it.
I've run across what I think is a bug illustrated below. I've made a waffle chart, and it's great:
However, I'm using a more polished version of this for a print document, and would like to add direct labels, one per group and with colors matching the fill of the waffle squares. I've done that by pulling out coordinates with
ggplot_build
and then adding ageom_text
layer to the waffle plot. But when I add something with a color aesthetic—here via some dummy text—an additional level"white"
gets added to the factor that makes the colors, and their levels get reset back to alphabetical order. One attempt settingcolor = "white"
manually, which still sets the border color properly but then adds this phantom level that shows up in the legend:Oddly, even with falling back on the default color argument (or setting it to any other color), this level still shows up:
I'm guessing something gets confused with having
color
arguments come from multiple places (or multiple spellings?). Here's the calculated data:Obviously I can work around this: using a named vector for colors with a dummy
white = NA
, or pulling the calculated data out and rebuilding the waffle squares myself. But I wanted to see if there is in fact a bug, or if I'm just trying to make it do too much.Thanks in advance.
Created on 2020-03-06 by the reprex package (v0.3.0)
The text was updated successfully, but these errors were encountered: