Skip to content

ggplotly geom_line vertical orientation is not working #4139

@ildnomde

Description

@ildnomde

ggplot2's geom_line allows setting the y-axis as the independent variable, by plotting in the order of how x is arranged:

library(tidyverse)
library(plotly)

c2 = c(1,2,3,4)
c1 = c(3,2,1,4)

dataset = data.frame(x=c1,y=c2)

p = ggplot(dataset %>%
         arrange(y), aes(x=x, y=y))+ 
  geom_point()+
  geom_line(orientation="y")+
  labs(
    y = "Depth", x = "Maximum concentration", 
  )+
  scale_y_reverse()
p

which results in:
image

however, this does not carry over when the plot is converted to plotly:
g = ggplotly(p) g
image

I noted that the plotly documentation does mention orientation as well.
https://plotly.com/ggplot2/line-charts/#vertical-plot-orientation

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