Hi, I'm having trouble with a reactive plot in R shiny. The goal of the plot is to show multiple points at once, based on user input. Depending on user input, the output results in a vertical line at 0, which I would like to remove. Additionally, I can't seem to get my plot to incorporate a color scheme. Code is below, and any help is appreciated!
# Server end of main screen plot
observeEvent(input$action,{
output$plot <- renderPlotly({
isolate({
x <- list(
title = "N Leaching [lbs/ac]"
)
y <- list(
title = "Yield"
)
plot <- plot_ly(
x = vals$Leachable,
y = vals$Yield,
type = 'scatter',
mode = 'markers',
marker = list(size = 10, color = brewer.pal(10,"Set3")),
)
plot <- plot %>% layout(xaxis = x, yaxis = y)
plot
})
})
})
#Server end of clear page button
observeEvent(input$reset_button, {js$reset()})
# Takes N Leaching and Yield values and plots them
observeEvent(input$action,{
observeEvent(c(vals$Leachable, vals$Yield), {
plotlyProxy("plot",session) %>%
plotlyProxyInvoke("addTraces",
list(x = c(vals$Leachable,vals$Leachable), # need at least 2 points
y = c(vals$Yield,vals$Yield),
type = "scatter",
mode = "markers",
marker = list(size=10),
color = brewer.pal(10, 'Set3')
)
)
})
})