Why is Shiny Cutting off ggplotly legend?

Hello,
My name is James, I am a relatively new R User and even newer to Shiny.
I am having this really annoying issue with my shiny apps that I have been unable to find a solution to. I was hoping there would be some help here!

When I run my shiny app and preview it in Rstudio everything works great, however, when I publish it the graphs are often cut like this:

The Code for that plot is:

  ggplotly(ggplot(fiscal_tidy_var, aes(as.numeric(month), Value, color = Delta))+
             geom_point(size = 2)+
             geom_line(size = 1.25, alpha = .75) +
             scale_x_continuous(breaks = 1:12, labels = c('Oct', 'Nov', 'Dec',
                                                          'Jan', 'Feb', 'Mar',
                                                          'Apr', 'May', 'Jun',
                                                          'Jul', 'Aug', 'Sep'))+
             xlab('Month') +
             ylab('Percent Delta') +
             geom_ribbon(aes(ymax = 0, ymin = max(min(Value), -100)),
                         fill="red",colour=NA,alpha=0.1) +
             geom_ribbon(aes(ymax = max(Value), ymin = 0),
                         fill="green",colour=NA,alpha=0.1) +
             theme_minimal() +
             ggtitle(input$Product_Class))

In the same app I have another page where it works fine(most of the time, not sure why theres variance)
(Cant add more than one image since im a new user)

Here is the code for that plot:

      ggplotly(ggplot(fiscal_tidy_var_filter, aes(as.numeric(month), Value, color = Delta))+
             geom_point(size = 2)+
             geom_line(size = 1.25, alpha = .75) +
             scale_x_continuous(breaks = 1:12, labels = c('Oct', 'Nov', 'Dec',
                                                          'Jan', 'Feb', 'Mar',
                                                          'Apr', 'May', 'Jun',
                                                          'Jul', 'Aug', 'Sep'))+
             xlab('Month') +
             ylab('Percent Delta') +
             geom_ribbon(aes(ymax = 0, ymin = max(min(Value), -100)),
                         fill="red",colour=NA,alpha=0.1) +
             geom_ribbon(aes(ymax = max(Value), ymin = 0),
                         fill="green",colour=NA,alpha=0.1) +
             theme_minimal() +
             ggtitle(input$Specify))

I have no idea what the issue could be, hoping someone here might have run into this before and found the answer

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.

I have a feeling updating plotly might automatically fix your issue, but if it doesn't, you could try specifying the height/width of the shiny output container in ggplotly(), as shown here -- https://github.com/ropensci/plotly/blob/master/inst/examples/shiny/ggplotly_sizing/app.R