R问题-在一个图形上绘制多条线
目前,我的代码最初允许用户选择他们想要的数据集(两种选择)。然后根据他们的选择,会出现数据集各自子集的其他绘图变量。这很好,除了我希望所有的图都覆盖在一个图上,而不是像默认情况下那样单独显示 我有一个默认的plot,plot_Total,数据集中的其他选项正在查看这个函数的特定子集。因此,只有一次散射是有意义的R问题-在一个图形上绘制多条线,r,shiny,R,Shiny,目前,我的代码最初允许用户选择他们想要的数据集(两种选择)。然后根据他们的选择,会出现数据集各自子集的其他绘图变量。这很好,除了我希望所有的图都覆盖在一个图上,而不是像默认情况下那样单独显示 我有一个默认的plot,plot_Total,数据集中的其他选项正在查看这个函数的特定子集。因此,只有一次散射是有意义的 output$plot_Total <- reactivePlot(function() { plot.new() plot.window(xlim=c(1850,2
output$plot_Total <- reactivePlot(function() {
plot.new()
plot.window(xlim=c(1850,2020), ylim = c(0,5000000))
axis(1)
axis(2)
title(main="Numbers over the years")
title(xlab="Year")
title(ylab="Number of people")
box()
points(dat$Year, dat$Total, col="red")
lines(dat$Year, dat$Total, col="red")
})
output$plot_subset1 <- reactivePlot(function() { lines(dat$Year, dat$subset1) })
output$plot_subset2 <- reactivePlot(function() { lines(dat$Year, dat$subset2) })
output$plot\u Total更新:通过在闪亮的主页上玩图形的代码,我意识到我必须这样做:
output$plot_Total <- reactivePlot(function() {
plot.new()
plot.window(xlim=c(1850,2020), ylim = c(0,5000000))
axis(1)
axis(2)
title(main="Numbers over the years")
title(xlab="Year")
title(ylab="Number of people")
box()
points(dat$Year, dat$Total, col="red")
lines(dat$Year, dat$Total, col="red")
if (input$RC) { lines(dat$Year, dat$dat)}
})
output$plot\u Total您是否查看了主页上的示例以了解更多信息?通过向现有绘图添加低级绘图命令,它似乎可以实现您想要的功能: