Skip to content
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

Some geoms always appear below others #866

Open
jvgogh opened this issue Feb 1, 2017 · 4 comments
Open

Some geoms always appear below others #866

jvgogh opened this issue Feb 1, 2017 · 4 comments

Comments

@jvgogh
Copy link

jvgogh commented Feb 1, 2017

Rendering of violin plots with box plots (to provide median & stddev) is in wrong order when using ggplotly.

library(ggplot2)
library(plotly)

p <- ggplot(iris,aes(Species,Sepal.Length))+
  geom_violin()+geom_boxplot(width=.1)
q <- ggplotly(p) 

the ggplot (p) will render as expected with violin plots:
ggplot

the ggplotly (q) will render with the box plot behind the violin plot (and larger than expected):
ggplotly

@cpsievert cpsievert added the bug label Apr 5, 2017
@cpsievert cpsievert added this to the ggplotly parity milestone Apr 6, 2017
@ifellows
Copy link

ifellows commented Mar 7, 2019

This also affects other geoms. Is there a plan to address this issue?

###Sample gaussian distributions with 1, 2 and 3 modes.
df <- data.frame(
  "Distribution" = c(rep("Unimodal", 500),
                     rep("Bimodal", 250),
                     rep("Trimodal", 600)),
  "Value" = c(rnorm(500, 6, 1),
              rnorm(200, 3, .7), rnorm(50, 7, 0.4),
              rnorm(200, 2, 0.7), rnorm(300, 5.5, 0.4), rnorm(100, 8, 0.4))
)
library(ggplot)
library(ggforce)

p <- ggplot(df, aes(Distribution, Value, color=Distribution))+ geom_sina() + geom_boxplot( outlier.alpha=0)
p
p %>% ggplotly()

Note also that the outliers are incorrectly printed (see the black dots) when they should be transparent and the legend is incorrect. Related: #1114

ggplot2:
image

plotly:
screen shot 2019-03-07 at 2 37 54 pm

@cpsievert
Copy link
Collaborator

It seems the root issue here is some plotly.js traces are always drawn below other traces plotly/plotly.js#3748

These examples should automatically fix themselves if and when plotly.js respects the ordering of traces...

@ifellows
Copy link

ifellows commented Apr 8, 2019

Thanks for looking into this. Is the outlier printing issue something that would automatically be fixed, or it that different?

@cpsievert
Copy link
Collaborator

That's a different problem that I have more control over.

@cpsievert cpsievert changed the title ggplotly violins with boxplot rendered incorrectly Some geoms always appear below others Apr 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants