talgalili / heatmaply

Interactive Heat Maps for R Using plotly
377 stars 73 forks source link

Observing - Rplot001.jpg being created as a 0kb image in my inst/shiny directory #275

Closed GreyMerchant closed 2 years ago

GreyMerchant commented 2 years ago

Describe the bug

When running the heatmaply function in shiny I tend to get a Rplot0001.jpg saved in my inst/shiny location with no size.

I have had this in a new build: R - 4.1.0 heatmaply - 1.3.0 ggplot2 - 3.3.5

and older build: R - 3.4.4 heatmaply - 1.1.0 ggplot2 - 2.2.1

To Reproduce

I am happy to create some sort of reprex for you if you require but I am getting no feedback from the terminal on this and I see at some point this was an issue:

Expected behavior

I am not expecting any images to be saved or created in this way from the function.

Additional context

I'd be happy to provide further info.

alanocallaghan commented 2 years ago

I am happy to create some sort of reprex for you if you require

Yes please do

GreyMerchant commented 2 years ago

Here is a full App.R code to run it and which shows the problem.

library(shiny)
library(heatmaply)

# Define UI for app that draws a histogram ----
ui <- fluidPage(

  # App title ----
  titlePanel("Hello Shiny!"),

  # Sidebar layout with input and output definitions ----
  sidebarLayout(

    # Sidebar panel for inputs ----
    sidebarPanel(

      # Input: Slider for the number of bins ----
      sliderInput(inputId = "bins",
                  label = "Number of bins:",
                  min = 1,
                  max = 50,
                  value = 30)

    ),

    # Main panel for displaying outputs ----
    mainPanel(

      # Output: Histogram ----
      plotlyOutput(outputId = "test_plotly")

    )
  )
)

# Define server logic required to draw a histogram ----
server <- function(input, output) {

  # Histogram of the Old Faithful Geyser Data ----
  # with requested number of bins
  # This expression that generates a histogram is wrapped in a call
  # to renderPlot to indicate that:
  #
  # 1. It is "reactive" and therefore should be automatically
  #    re-executed when inputs (input$bins) change
  # 2. Its output type is a plot

  output$test_plotly <- renderPlotly({

    heatmaply(iris[,-5], k_row = 3, k_col = 2)

  })

}

shinyApp(ui, server)

################## I have attached an image of my session as well so you have all other info.

image

GreyMerchant commented 2 years ago

R_code.txt

I just uploaded the code I used in a .txt so it doesn't format so odd.

alanocallaghan commented 2 years ago

You can use triple backticks (```) to format a code block in github flavoured markdown (I've edited your comment thus)

alanocallaghan commented 2 years ago

This doesn't make an Rplot0001 for me, might be a Windows issue. Will check later

GreyMerchant commented 2 years ago

Any updates here? :)

alanocallaghan commented 2 years ago

I'm pretty sure this happens because ggplotGrob requires an open graphics device. If this really bothers you, then replace

heatmaply(iris[,-5], k_row = 3, k_col = 2)

with

heatmaply(iris[,-5], k_row = 3, k_col = 2, plot_method = "plotly")
GreyMerchant commented 2 years ago

Thanks for the explanation. That did resolve it. Given this will live in a shiny app I can't have it create files there

alanocallaghan commented 2 years ago

Cheers. I'd try fix the issue with the ggplot2 version, but it's a "wontfix" issue in ggplot2 and I could never find a workaround https://github.com/tidyverse/ggplot2/issues/809