R 在shiny中使用交互式绘图可视化镶嵌面数据

R 在shiny中使用交互式绘图可视化镶嵌面数据,r,shiny,data-visualization,plotly,ggvis,R,Shiny,Data Visualization,Plotly,Ggvis,在我的数据中创建交互式绘图时遇到了一些问题。 这里有一些代码显示了我想要的内容,但它使用了非交互式的ggplot2 library(shiny) library(data.table) library(ggplot2) x <- 1:10000 dt <- data.frame(a = 1:100, b = sample(x,100,replace=T), c = sample(x,100,replace=T), d = sample(x,100,replace=T)) dt.mo

在我的数据中创建交互式绘图时遇到了一些问题。 这里有一些代码显示了我想要的内容,但它使用了非交互式的
ggplot2

library(shiny)
library(data.table)
library(ggplot2)

x <- 1:10000
dt <- data.frame(a = 1:100, b = sample(x,100,replace=T), c = sample(x,100,replace=T), d = sample(x,100,replace=T))
dt.molten <- melt(dt,id.vars="a")


ui <- fluidPage(
   plotOutput("gplot")
)

server = function(input, output) {

  output$gplot <- renderPlot({
    ggplot(y.molten,aes(x = value)) + 
      geom_histogram(binwidth = 100000) + 
      facet_wrap( ~ variable,ncol = 1)

  })

}

shinyApp(ui = ui, server = server)
除了使用直方图而不是时间序列数据

主要问题是,我绘制的数据范围从-3000000到+3000000,高度集中在0左右。这使得很难看到边缘的条形图,因此我希望用户能够放大绘图的特定范围,而无需通过某些ui元素进行选择

我愿意接受在R中使用任何绘图方法的建议,尽管我想远离
rCharts


编辑:我确实发现使用
plotly::ggplotly
几乎达到了我想要的效果,但是它不是很干净。我做了
g您可以使用ggplot2制作交互式绘图
shiny
。特别是缩放的概述和示例。这是一个可靠的选项,谢谢。
require(highcharter)
x <- stl(log(AirPassengers), "per")
hchart(x)