Closed krlmlr closed 5 years ago
This looks to be the same as in ggplot2 so this would have to be fixed upstream first. Can you file there please?
I think the problem is unique to ggstance.
In the original (vertical) plot, the colors go from left to right, and correspond to the legend order from top to bottom. This is expected. With ggstance, left becomes bottom and right becomes top, and the colors go from bottom to top while the legend remains unchanged. Also, the labels on the y-axis are in reverse alphabetical order, it seems more natural to have the alphabetical order running from top to bottom in this kind of plot.
Perhaps we just need geom_boxplothr()
and friends (for r = reverse)? Or stat_rev()
?
library(tidyverse)
mpg %>%
ggplot(aes(x = class, y = cty, fill = drv)) +
geom_boxplot()
Created on 2018-07-21 by the reprex package (v0.2.0).
The original issue can be solved with reverse = TRUE
, maybe this should be the default (or inverted internally)?
library(tidyverse)
library(ggstance)
#>
#> Attaching package: 'ggstance'
#> The following objects are masked from 'package:ggplot2':
#>
#> geom_errorbarh, GeomErrorbarh
mpg %>%
ggplot(aes(x = cty, y = class, fill = drv)) +
geom_boxploth(position = position_dodge2v(padding = 0, reverse = TRUE))
Created on 2018-11-08 by the reprex package (v0.2.1.9000)
(At least half of it -- it's easy enough to reverse the order of the vertical axis manually, but I still feel top-down is the most intuitive order, and ggstance could make it easier for the user to achieve it.)
Thanks! So little code, so much bugfix!
The labels on the vertical axis are still reversed, though. This seems difficult to fix.
library(tidyverse)
library(ggstance)
mpg %>%
ggplot(aes(x = cty, y = class, fill = drv)) +
geom_boxploth()
Created on 2019-07-09 by the reprex package (v0.3.0)
We discussed it with @friep and @sowla and concluded the ordering of labels is right, because the bottom left corner is the origin.
conflicts with order in which geoms are put by
position_dodgev()
.In the plot I would expect the fill color to go from red to green to blue in the plot, corresponding to the legend.