Skip to content

Does not respect space = "free" in facet_grid #908

Open

Description

@stanstrup
mt <- ggplot(mtcars, aes(mpg, wt, colour = factor(cyl))) + geom_point()
p <- mt + facet_grid(. ~ cyl, scales = "free", space = "free")

p
image

ggplotly(p)
image

Activity

  1. added this to the ggplotly parity milestone on Apr 6, 2017
  2. Mschwindi commented on Apr 9, 2020

    @Mschwindi

    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) 
    

    image

  3. choogland commented on Apr 22, 2020

    @choogland

    Issue still there. Any chance this will be fixed ?
    We want to use ggplot free scale feature in combination with plotly tooltip.
    Thanks!

  4. Thonnard commented on Jul 28, 2021

    @Thonnard

    Issue is still present. Would be nice to see this fixed. Thank you!

  5. Zhenglei-BCS commented on Oct 20, 2021

    @Zhenglei-BCS

    Same issue here.

  6. federicotallis commented on Jan 26, 2022

    @federicotallis

    Would be really helpful if this issue could be fixed.

  7. xinyixinyijiang commented on May 12, 2022

    @xinyixinyijiang

    same here :<

  8. fuhred commented on Jun 14, 2022

    @fuhred

    Same issue

  9. wbelzak commented on Aug 19, 2022

    @wbelzak

    Same issue :/

  10. MaggieLuCB commented on Mar 19, 2023

    @MaggieLuCB

    same issue here

  11. xueyuanj commented on Jun 9, 2023

    @xueyuanj

    Same issue here

  12. mariecrane commented on Oct 31, 2023

    @mariecrane

    Same issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions