Question: Plotting multiple line plots using ggplot2 and save as pdf
gravatar for mohammedtoufiq91
14 months ago by
mohammedtoufiq91110 wrote:


I have the long format data created for the purpose of the line plot. Each gene is mapped to unique ID arranged in the last column which would be beneficial during plotting. Example of the data is mentioned below and along with the screenshot of the output. I have two questions,

  1. This is plotted just with the few IDs (last column), I have more than hundred IDs and saving the pdf looks fuzzy. Is there a way to include all the plots corresponding to the ID by setting margins in the pdf report.

  2. Include the gene names inside each ID box, as separate legend occupies more space and not very interpretive in case of large data.

Please assist me with this.

Multiple line plots

structure(list(Genes = structure(c(1L, 1L, 1L, 1L, 2L, 2L), .Label = c("Gene_A", 
"Gene_B", "Gene_C", "Gene_D", "Gene_E", "Gene_F", "Gene_G", "Gene_H", 
"Gene_I", "Gene_K", "Gene_L", "Gene_M", "Gene_N", "Gene_O", "Gene_P", 
"Gene_R", "Gene_S", "Gene_T"), class = "factor"), Timepoints = c("1", 
"2", "3", "5", "1", "2"), value = c("-2.05066", "-0.657222", 
"-1.49477", "-1.80191", "-8.35787", "-9.52402"), X5 = structure(c(Gene_A = 1L, 
Gene_A = 1L, Gene_A = 1L, Gene_A = 1L, Gene_B = 2L, Gene_B = 2L
), .Label = c("A1.1", "A1.2", "A1.3", "A1.4", "A1.5", "A1.6", 
"A1.9", "A2.2", "A2.6"), class = "factor")), row.names = c(NA, 
6L), class = "data.frame")

final %>% 
      ggplot(aes(x =  Timepoints , y = value , group = Genes)) +   
      geom_point() +  
      geom_line(alpha = 1 , aes(col = as.character(Genes))) + 
      theme_bw() +  
      theme(legend.position = "right" , axis.text.x = element_text(angle = 90 , vjust = 0.4)) +

Thank you,


cowplot lineplot ggplot2 R • 1.6k views
ADD COMMENTlink modified 11 months ago by Biostar ♦♦ 20 • written 14 months ago by mohammedtoufiq91110

See this related StackOverflow post:

ADD REPLYlink written 14 months ago by zx87549.9k

@ zx8754,

Thank you very much for the suggestions.

ADD REPLYlink written 14 months ago by mohammedtoufiq91110
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1499 users visited in the last hour