Skip to content

geom_area position_stack order appears to have changed #2778

Closed

Description

@ptoche

The default order of the data in geom_area() has changed. The order is no longer the order shown in the manual https://ggplot2.tidyverse.org/reference/position_stack.html

Was that intended? Is it documented?

series <- data.frame(
    time = c(rep(1, 4),rep(2, 4), rep(3, 4), rep(4, 4)),
    type = rep(c('a', 'b', 'c', 'd'), 4),
    value = rpois(16, 10)
)
library(ggplot2)
ggplot(series, aes(time, value)) +
    geom_area(aes(fill = type))

ggplot(series, aes(time, value)) + 
    geom_area(aes(fill = type), position = position_stack(reverse = TRUE))

Created on 2018-07-26 by the reprex package (v0.2.0).

Compare the above with the relevant part of the manual:

# Stacking is also useful for time series
series <- data.frame(
  time = c(rep(1, 4),rep(2, 4), rep(3, 4), rep(4, 4)),
  type = rep(c('a', 'b', 'c', 'd'), 4),
  value = rpois(16, 10)
) 
ggplot(series, aes(time, value)) +
  geom_area(aes(fill = type))

https://ggplot2.tidyverse.org/reference/position_stack-5.png

Activity

  1. ptoche commented on Jul 30, 2018

    @ptoche
    Author

    An example from plots I made a couple of years ago.

    Before:

    figure_1_1_old

    After:

    figure_1_1_new

  2. karawoo commented on Jul 30, 2018

    @karawoo
    Member

    It looks the same in the manual to me?

    screen shot 2018-07-30 at 8 30 31 am

    I do think the stack order changed at some point but it was a while ago in 2.2.0.

  3. ptoche commented on Aug 1, 2018

    @ptoche
    Author

    @karawoo, You're probably right. My plots are from February 2015, so this may well be an old change.

    The example from the manual confused me because I got a plot that looked quite different and assumed it was a common cause. The real reason is that the data used in the example is random. It might be useful to set a seed before the data is created to make it clearer, e.g.

    set.seed(1)
    series <- data.frame(
        time = c(rep(1, 4),rep(2, 4), rep(3, 4), rep(4, 4)),
        type = rep(c('a', 'b', 'c', 'd'), 4),
        value = rpois(16, 10)
    )
    ggplot(series, aes(time, value)) +
        geom_area(aes(fill = type))
    
  4. lock commented on Jan 28, 2019

    @lock

    This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/

  5. locked and limited conversation to collaborators on Jan 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions