Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9108405
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T02:48:04+00:00 2026-06-17T02:48:04+00:00

I am using ggplot to graph a number of data sets, however I would

  • 0

I am using ggplot to graph a number of data sets, however I would like to plot them so that each data set has its own geom_line function so that I can seperate the lines out and hide them if required.

 ggplot(MeanFrameMelt, aes(x=variable, y=value, 
           color=Legend, group=Legend)) + geom_line()

Input table after transformed with the melt function in the package reshape:

Legend        variable  value
table_A.txt V1  0.008927491
table_B.txt V1  0.009080929
table_C.txt V1  0.008513332
table_D.txt V1  0.008337751
table_A.txt V2  0.008957742
table_B.txt V2  0.009100265
table_C.txt V2  0.008508966

table A should be one geom_line (line on the graph) table B a second geom_line and so on. Is this possible or do I have to go back and change the melting of the previous data frame?

Edit:
ok this is the melt function:

library(plyr)
library(reshape)    
MeanFrameMelt <- melt(MeanFrame2, id.vars="Legend")

The data i’ve given you is of only two points for each line, so imagine you have hundreds of points from each table (A, B, C, and D) hence there will be four lines on this graph. I want to be able to switch off each line with a checkbox, but for this I need to have a unique identifier for each line which will allow me to do this. So what I was thinking is to do a seperate + geom_line(for table A) + geom_line(for table B) + geom_line(for table C)...

I hope this clarifies thinks a bit.

Edit2: this is what the graph looks like now, and it should look like this after aswell, but with 4 geom_line calls instead of just one that it has now:

enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T02:48:05+00:00Added an answer on June 17, 2026 at 2:48 am

    I think this is close to what you want:

    ggplot(MeanFrameMelt, aes(x=variable, y=value, 
           color=Legend, group=Legend))+ geom_line(aes(linetype=Legend))
    

    Edit After OP clarification

    With ggplot2( Lattice also) you can combine data sources and subsetting for each layer

    Here for example I choose to show only 2 lines

    library(ggplot2)
      ggplot(dat, aes(x=variable, y=value, ,
                              color=Legend, group=Legend))+ 
      geom_line(subset= .(Legend %in% c('table_A.txt','table_D.txt')))
    

    enter image description here

    You can bind your check box to the list of line to show.

     geom_line(subset= .(Legend %in% visibleCheckedList))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using ggplot to plot some data. It works fine but I'd like
would like to create a function that generates graphs using ggplot. For the sake
I am using ggplot2 to plot a figure that contains nine facets. Each facet
I am making a dotplot using ggplot with the code and data that is
I am using knitr with plots. I would like to rotate one of them
I wanted to plot time series data in R by using ggplot but I
Basically I'd like to create the first plot shown below in R using ggplot,
I'm using this data set (at the bottom) to create a density plot, but
I'm an R/ggplot newbie. I would like to create a geom_line plot of a
I am using ggplot to plot time course data (fixation proportions over time to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.