I have a shiny app like the following:
server.R
:
shinyServer(function(input, output) {
output$trendPlot <- renderPlotly({
plot_ly(movies, x = length, y=rating, mode='markers', color=as.factor(year), colors = c("#132B43", "#56B1F7")) -> plott
plott
})
})
ui.R
:
library(shiny)
library(plotly)
library(ggplot2movies) # Needed for the 'movies' data set
shinyUI(fluidPage(
titlePanel("Movie Ratings!"),
mainPanel(
plotlyOutput("trendPlot")
)
))
This produces a warning:
Warning in RColorBrewer::brewer.pal(N, "Set2") :
n too large, allowed maximum for palette Set2 is 8
Returning the palette you asked for with that many colors
I would like to suppress this warning because it's unnecessarily cluttering up my logs (yes, I know how to actually get rid of this warning by fixing the issue. But this is for illustrative purposes only. In my actual shiny app there is no getting rid of the warning).
Wrapping the final plott
in renderPlotly()
in suppressWarnings()
does not work. Changing plott
to suppressWarnings(print(plott))
does work but also prints the plot outside of the UI context. Can this be done cleanly?