plotly.R
plotly.R copied to clipboard
Does not respect space = "free" in facet_grid
mt <- ggplot(mtcars, aes(mpg, wt, colour = factor(cyl))) + geom_point()
p <- mt + facet_grid(. ~ cyl, scales = "free", space = "free")
p
ggplotly(p)
Hi have a workaround using plotly's subplot function. Still needs further tuning, so please keep adding.
library(plotly)
library(tidyverse)
#define plot yaxis limits
limits <- mtcars %>%
summarise(max = ceiling(max(wt*1.1)),
min = floor(min(wt*0.9)))
#define width of subplots by finding the absolut range of each "facet"
plot_width<- mtcars %>%
group_by(cyl) %>%
summarise(range = range(mpg)[2]-range(mpg)[1]) %>%
ungroup() %>%
mutate(width_pct = range/sum(range))
#define a list of ggplot and feed it in the subplot function with the calculated limits
mtcars %>%
split(.$cyl) %>%
map(function(x) {
ggplot(data=x,aes(mpg,wt)) + geom_point(size=2)+
facet_grid(.~cyl) + ylim(c(limits$min,limits$max))
}) %>%
subplot(margin = 0.005, shareY = T,widths = plot_width$width_pct)
Issue still there. Any chance this will be fixed ?
We want to use ggplot free scale feature in combination with plotly tooltip.
Thanks!
Issue is still present. Would be nice to see this fixed. Thank you!
Same issue here.
Would be really helpful if this issue could be fixed.
same here :<
Same issue
Same issue :/
same issue here
Same issue here
Same issue