Search code examples
rggplot2shinyshiny-reactivityggtern

ternary plot of ggtern not working in shiny


I want to use the output of ggtern() in a shiny app. However it seems to fail due to some constraints.

This is what it should look like: What is should look like

This is the actual shiny output: The output in shiny

See here for a reproducible example:

library(shiny)
library(ggtern)

ui <- fluidPage(
        mainPanel(
           plotOutput("ggtern")
        )
)
server <- function(input, output) {
    output$ggtern <- renderPlot({
        ggtern(data.frame(x=10, y=30, z=60), aes(x, y, z)) + geom_point()
    })
}
shinyApp(ui = ui, server = server)

Do I overlook something?


Solution

  • place the plot function within a print command:

     output$ggtern <- renderPlot({
            print(ggtern(data.frame(x=10, y=30, z=60), aes(x, y, z)) + geom_point())
        })