Skip to content

Incorrect Background Fill when violin plot generated by ggplot is piped into toWebGL() #1693

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

Closed
wdm0336 opened this issue Feb 5, 2020 · 4 comments

Comments

@wdm0336
Copy link

wdm0336 commented Feb 5, 2020

Generating a series of violin plots with vertical facets. The background color is not filled completely in the entire background when the ggplot object is sent thru toWebGL(). If I generate boxplots instead of violin plots, things seem to work. If I don't use faceting, things appear to be correct.

A picture is worth a 1000 words so check out the "with" and "without" toWebGL().
plot_with_toWebGL
plot_without_toWebGL

# Data set is attached. load into data_frame() called 'dat'

library(ggplot2)
library(dplyr)
gg <- ggplot(dat, aes(x = Axis, y = Value))
gg <- gg + geom_violin(scale = "width", aes(color = group_color))
gg <- gg + geom_jitter(shape = 16, position = position_jitter(0.2), 
    aes(text = hover_text))
gg <- gg + facet_grid(Vert ~ .)
gg <- gg + guides(color = FALSE)
gg <- gg + ylim(0, 1) + ylab("Score")
gg <- gg + xlab("Attributes")
gg <- gg + ggtitle("Violin Plot of Data")
gg <- gg + theme_minimal()
gg <- gg + theme(legend.position = "none",
	plot.title = element_text(size = 20, hjust = 0.5), 
	panel.grid.major = element_blank(),
	panel.background = element_rect(fill = "grey90"),
	axis.text.y = element_text(size = 10),
	axis.title.y = element_text(size = 16),
	panel.grid.major.y = element_line(linetype = "dotted"),
	axis.text.x = element_text(size = 10, angle = 90, hjust = 1),
	axis.title.x = element_text(size = 16),
	strip.text.x = element_text(size = 10),
	strip.text.y = element_text(size = 10),
	plot.margin = margin(0, 2, 0, 2, "cm"))

print(gg)
print(gg) %>% toWebGL()

dat.csv.zip

@cpsievert
Copy link
Collaborator

cpsievert commented Feb 5, 2020

Likely a result of plotly/plotly.js#2291, so unfortunately there's isn't much I can do fix...is there a reason why you need toWebGL() over ggplotly() (the latter renders ok, right)?

@wdm0336
Copy link
Author

wdm0336 commented Feb 6, 2020

ggplotly renders correctly (without toWebGL). We are using toWebGL() to reduce the time it takes to generate the plot when there is a lot of data.

@cpsievert
Copy link
Collaborator

Ok, unfortunately there's isn't anything I can do in the R package to workaround this problem...the fix must come from plotly.js, so I'll be closing this...subscribe to plotly/plotly.js#2291 for updates

PS. thanks for the reprex!

@wdm0336
Copy link
Author

wdm0336 commented Feb 6, 2020 via email

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

No branches or pull requests

2 participants