r - 在同一个图表上绘制不同的行

标签 r plot

我发现了一个关于绘图的有趣主题,但我对答案不满意。我想在同一个图表上绘制不同数量的行。只是让我可以添加尽可能多的行。

我想使用 glopts 库,但我对任何其他库持开放态度。首先,我想将这些行绘制成 pdf 文件。我要修改的脚本是:

which_rows <- c(12,156,4432) ## I want to choose which row I want to plot

pdf(file='Plots'.pdf)

x <- 1:(ncol(data_plot)-1) ## Can it be changed to use the name of the columns instead of pure numbers ?

for(i in which_rows){
 ## create new pdf page BUT I WANT TO PLOT IT ON THE SAME GRAPH!
  plot(x=x,y=data_plot[i,-1],type='b',main=data_plot[i,1],xlab='columns',ylab='Intensity')
}

# closing pdf
dev.off()

你能帮我修改这个脚本以仅打印我在同一个图表上决定的所有行吗?如果您向我展示如何使用其他行集(例如 which_rows2)在此 pdf 文件中添加新页面,那就太好了。

当然,每个图应该有不同的颜色或其他东西。

编辑:

Just one of the plots from my data. I want different colours and plots on the same graph

最佳答案

使用points()将点添加到现有绘图

关于r - 在同一个图表上绘制不同的行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26120976/

相关文章:

r - r : edge labels are overlapping 中的 igraph 包

matlab - 为什么 matlab plot 使用这么多内存?

R:将 "special"字母转换为 UTF-8?

用 r 中的值替换数据集中的空白

r - 通过循环在renderUI中创建Value Box

R/Shiny - 如何使用 Sys.Date() 获取当前年份?

r - 如何在 R 中每隔一行添加一个字符串?

r - 在 R 图形窗口中组合基本图形和 ggplot 图形

python - 如何使用辅助 Y 绘制具有分组索引的 DataFrame

plot - 如何使用非数字 X 轴绘制数据?