Skip to content

orientation for geom_step() #5936

Closed
@vgregoire1

Description

@vgregoire1

(First time posting, feedback is welcome!)
When a vertical phenomenon must be represented (ex. depth or height profile) , geom_line(orientation = "y") could be use. I don't think that there is similar way to use geom_step(), since orientation is not an argument for that function.

I would like to be able to use the orientation ="y" in geom_step(). My actual workaround is to use the superseeded coord_flip(). I completely aggree with its documentation...

This function is superseded because in many cases, coord_flip() can easily be replaced by swapping the x and y aesthetics, or optionally setting the orientation argument in geom and stat layers.

... but it does not seem to be the case for geom_step()

The following example:

library(tidyverse)
#> Warning: le package 'ggplot2' a été compilé avec la version R 4.3.3
df = data.frame(height= c(0:10), var1= c(0,1,5,2,1,5,4,9,8,7,7))

# geom_line() way to represent a soil profil
ggplot(df, aes(x=var1, y = height)) + geom_line(orientation = "y")

# geom_step() doesn't take `orientation`
ggplot(df, aes(x=var1, y = height))  +geom_step(orientation = "y")
#> Warning in geom_step(orientation = "y"): Ignoring unknown parameters:
#> `orientation`

# The proper way seems to use the superseeded `coord_flip()`
ggplot(df, aes(x=height, y = var1))  +geom_point()+
  geom_step() +
  coord_flip()

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions