plotly / plotly/plotly.R

using ggforce paginated figures with ggplotly

Open
#2,164 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
R
Stars
2.7k
Forks
641
PR merge metrics
No merged PRs in 30d

Description

Hello, I'm currently trying to use ggforce::facet_wrap_paginate to take figures with many facets and chop them up to make them easier for folks to view in a Shiny App. I can render these with ggplot just fine, but when I try to use poorly it just puts all of the facets on the same figure. The code below reproduces the problem, and the output I see shown as well. The figure on the top is paginated ggplot output and the one below is the paginated plotly output.

Any help would be most appreciated.

library(plotly)
library(ggplot2)
library(ggforce)


ui <- fluidPage(
  plotOutput("page2_ggplot"),
  tags$br(),
  plotly::plotlyOutput("page2_ggplotly")
)

server <- function(input, output) {
  
  tmpds = diamonds[1:1000,]

  output$page2_ggplot   = renderPlot({
    p = ggplot(tmpds) +
      geom_point(aes(carat, price), alpha = 0.1) +
      facet_wrap_paginate(~ cut:clarity, ncol = 3, nrow = 3, page = 2)
    
    res = p
  res})
  
  output$page2_ggplotly   = plotly::renderPlotly({
    p = ggplot(tmpds) +
      geom_point(aes(carat, price), alpha = 0.1) +
      facet_wrap_paginate(~ cut:clarity, ncol = 3, nrow = 3, page = 2)
    res = plotly::ggplotly(p)
  res})
}

# Run the application 
shinyApp(ui = ui, server = server)
image

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the supplied Shiny app and compare the renderPlot output with renderPlotly and ggplotly using facet_wrap_paginate(page = 2). Trace how the paginated facet settings are handled in the Plotly conversion, and consider the issue done when the plotly output displays only the requested page of facets.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
data-visualization
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.