ternary plot of ggtern not working in shiny

天涯浪子 提交于 2020-06-02 03:40:44

问题


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:

This is the actual shiny output:

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?


回答1:


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())
    })


来源:https://stackoverflow.com/questions/55101305/ternary-plot-of-ggtern-not-working-in-shiny

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!