Skip to content

Example of flipped aes on geom_area() needs orientation? #3590

Closed
@yutannihilation

Description

@yutannihilation

The third figure on the examples section of geom_ribbon/geom_area seems a bit confusing to me.

cc @thomasp85

The comment says

# Change orientation be switching the mapping

and I expected the left one below, but actually got the right one. Is the figure intended? Or, is this an example of failure to show the necessity of explicitly setting orientation = "y"?

library(ggplot2)

huron <- data.frame(year = 1875:1972, level = as.vector(LakeHuron))

# expected one?
p1 <- ggplot(huron) +
  geom_area(aes(x = year, y = level)) +
  coord_flip() +
  ggtitle("flipped by coord")

# orientation = "y"?
p2 <- ggplot(huron) +
  geom_area(aes(x = level, y = year)) +
  ggtitle("flipped by aes")

patchwork::wrap_plots(p1, p2)

Created on 2019-10-27 by the reprex package (v0.3.0)

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