'Code written with some packages gives blank output inside renderPlot function
The plot function of some packages like timetk, plot_ly does not produce the plot(output) written inside renderPlot function. Although the same piece of code returns the output(plot) when I run it in console. Whereas function like plot(), ggplot() does the work too.
Why is that so?
This piece of code with timetk library provide the output in rstudio console:
dataset %>%
plot_time_series(.date_var = Year, .value = column1,
.interactive = TRUE, .y_lab = "Amt", .x_lab = "Year",
)
But if this same piece is written inside renderPlot function, it does not provide the output on RShiny app, just shows a blank white screen.
UI: UI code is all good. I also have written an plotOutput("p1") too.
Server:
output$p1 <- renderPlot({
dataset %>%
plot_time_series(.date_var = Year, .value = column1,
.interactive = TRUE, .y_lab = "Amt", .x_lab = "Year",
)
})
Solution 1:[1]
The issue is (was) that renderPlot and plotOutput are meant for base plots or ggplots. As you want to make an interactive plotly chart you have to make use of plotly::renderPlotly and plotly::plotlyOutput.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | stefan |
