Coder Social home page Coder Social logo

Order of items in legend about ggstance HOT 6 CLOSED

lionel- avatar lionel- commented on August 18, 2024
Order of items in legend

from ggstance.

Comments (6)

lionel- avatar lionel- commented on August 18, 2024 1

We discussed it with @friep and @sowla and concluded the ordering of labels is right, because the bottom left corner is the origin.

from ggstance.

lionel- avatar lionel- commented on August 18, 2024

This looks to be the same as in ggplot2 so this would have to be fixed upstream first. Can you file there please?

from ggstance.

krlmlr avatar krlmlr commented on August 18, 2024

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).

from ggstance.

krlmlr avatar krlmlr commented on August 18, 2024

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)

from ggstance.

krlmlr avatar krlmlr commented on August 18, 2024

(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.)

from ggstance.

krlmlr avatar krlmlr commented on August 18, 2024

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)

from ggstance.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.