Hello,
Nice:
gg <- ggplot(iris, aes(x=Sepal.Length, y=Sepal.Width)) +
geom_point() +
facet_wrap("Species", scales = "free_y")

Not nice:
ggplotly(gg)

> sessionInfo()
R version 3.3.3 (2017-03-06)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
locale:
[1] LC_COLLATE=French_Belgium.1252 LC_CTYPE=French_Belgium.1252
[3] LC_MONETARY=French_Belgium.1252 LC_NUMERIC=C
[5] LC_TIME=French_Belgium.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] purrr_0.2.3 shinythemes_1.1.1 shinyjs_0.9.1 plotly_4.7.1
[5] ggthemes_3.4.0 ggplot2_2.2.1.9000 shiny_1.0.5
Adding a link to my post on this issue at StackOverflow:
Oh my, quite annoying. It would be great if somebody would have a chance to look into this. A workaround may be to stack everything into one column.
ggplotly(
ggplot(
aes(
x = x,
y = y),
data = data) +
geom_point() +
facet_wrap(~measure, scales = "free_y", ncol = 1)
)

While the next solution doesn't work for this particular iris dataset case, it works for mine. Try swapping number of columns and rows.
I had this issue as well a couple of weeks ago. Updating to the latest plotly version resolved the issue:
devtools::install_github("ropensci/plotly")
This issue appears to have returned, assuming it was resolved. I'm using latest dev version 4.8.0.9000 and have a very pronounced variation in any 5+ columns facet_wrap.
Can confirm, a facet_wrap with scales = "free" breaks plotly.
Can confirm this issue has returned, as well. scales = "free_y" produces uneven widths still:
p <- ggplot(tmp_dat, aes(x = delivery_week, y = est_spend, color = topic,
text = paste0(
topic, "\n", friendly_number(est_spend, 1, TRUE)
),
group = 1)) +
geom_point() +
geom_line() +
facet_wrap(~ label, scales = "free_y") +
theme_light() +
theme(text = element_text(size = 16)) +
scale_y_continuous(label = function(x) friendly_number(x, 1, TRUE)) +
labs(x = NULL, y = NULL) +
scale_color_manual(
name = "Topic",
values = c("#E69F00", "#56B4E9", "#009E73",
"#F0E442", "#0072B2", "#D55E00")
)
ggplotly(p, tooltip = "text") %>%
layout(font = list(family = "Roboto"), height = 800, autosize = TRUE) %>%
config(displayModeBar = FALSE)

Removing the scales argument yields:

The issue is still there. @cpsievert can you re-open this?
The original example works. Feel free to open a new issue if you have another minimal reproducible example
@cpsievert it's exactly the same for me.
Here's how ggplot looks like.
ggplot(iris, aes(x=Sepal.Length, y=Sepal.Width)) +
geom_point() +
facet_wrap("Species", scales = "free_y")

Here's how it looks like with ggplotly:
gg <- ggplot(iris, aes(x=Sepal.Length, y=Sepal.Width)) +
geom_point() +
facet_wrap("Species", scales = "free_y")
ggplotly(gg)

Notice the difference in column widths.
Here's my sessionInfo():
R version 3.6.1 (2019-07-05)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Mojave 10.14.6
Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] plotly_4.9.0.9000 ggplot2_3.2.0 RPostgreSQL_0.6-2 DBI_1.0.0
Bug over 2 years old now. Is there any movement to fix?
Bug still there. I have line plot with each category as a line, "scale = 'free_y'" turns my categorical axis into numeric when translate to ggplotly. Any update on this?
Is this related to Issue 1086?
I'm still having the problem (plotly Version: 4.9.2.1)
Most helpful comment
@cpsievert it's exactly the same for me.
Here's how
ggplotlooks like.Here's how it looks like with
ggplotly:Notice the difference in column widths.
Here's my
sessionInfo():