Skip to content

Add geom_step(orientation) argument #5937

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jul 11, 2024

Conversation

teunbrand
Copy link
Collaborator

This PR aims to fix #5936.

Briefly, it adds the orientation argument to geom_step().
If orientation = "y", stairsteps are constructed vertically.

In the example below, recall that the steps go from top to bottom, so direction = "hv" first does the horizontal step, then the vertical one (and vice versa for direciton = "vh").

devtools::load_all("~/packages/ggplot2/")
#> ℹ Loading ggplot2

recent <- economics[economics$date > as.Date("2013-01-01"), ]
ggplot(recent, aes(date, unemploy)) +
  geom_point(shape = 21, size = 3, fill = "white") +
  geom_step(aes(colour = "hv"), orientation = "y", direction = "hv") +
  geom_step(aes(colour = "vh"), orientation = "y", direction = "vh") +
  geom_step(aes(colour = "mid"),orientation = "y", direction = "mid")

Created on 2024-06-07 with reprex v2.1.0

Copy link
Member

@thomasp85 thomasp85 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@teunbrand teunbrand merged commit 01eff23 into tidyverse:main Jul 11, 2024
11 checks passed
@teunbrand teunbrand deleted the step_orientation branch July 11, 2024 18:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

orientation for geom_step()
2 participants