显示ggplot中geom_hex的数量

时间:2015-11-27 03:48:23

标签: r ggplot2 shiny-server

我试图在使用ggplot和geom_hex时显示十六进制值的计数。我可以显示x / y坐标,但是如何访问计数则丢失了。提前谢谢

ui <- basicPage(
  plotOutput("plot1", brush = "plot_brush",click="plot_click"),
  verbatimTextOutput("info")
)

server <- function(input, output) {
  d <- data.frame(x=runif(1000),y=runif(1000))
  output$plot1 <- renderPlot({



  # z<- ggplot(d, aes(x, y, fill = ..count..)) +
     z<- ggplot(d, aes(x, y)) +
     geom_hex(bins=10)
      # geom_point()
   z
  })

  output$info <- renderPrint({
    # With base graphics, need to tell it what the x and y variables are.
    #brushedPoints(d, input$plot_brush, xvar = "V1", yvar = "V2")
    nearPoints(d,input$plot_click,threshold = 10, maxpoints = 1,addDist = TRUE)
  })
}

shinyApp(ui, server)

0 个答案:

没有答案