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 7413271
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:40:12+00:00 2026-05-29T06:40:12+00:00

I have the following data set called t : n <- 12 t <-

  • 0

I have the following data set called t:

n <- 12
t <- data.frame(
  V1    = runif(n, 0.12, 0.35),
  V2    = runif(n, 0.25, 0.39),
  group = gl(3, 4, labels = c("a1", "a2", "a3")),
  x     = seq_len(n),
  color = rep(rep.int(c("R", "G"), 2), c(3, 4, 3, 2))
)

I created the following plot from this data.

p <- ggplot(t, aes(x, colour = color)) +  
  geom_point(aes(y = V1, size = 10)) + 
  geom_point(aes(y = V2, size = 10))

What I want to do now is to connect the points depending on the group column (e.g, points of group a1 will be connected with a blue line, points of group a2 will be connected in a yellow line, …) and i want the line to be different depending on V1 and V2 (dashed line for V1 and normal line for V2).

How this can be done?

  • 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-05-29T06:40:12+00:00Added an answer on May 29, 2026 at 6:40 am

    First of all: naming a dataset “t” is not a good idea because it is confusing since there is a function t() as well.

    The easiest way is to melt() your dataset first

    Molten <- melt(t, id.vars = c("group", "x", "color"))
    ggplot(Molten, aes(x = x, y = value, colour = group, linetype = variable)) + geom_line()
    

    Have a look at the ggplot2 website on how to customise the colours.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following data set that I am trying to plot with ggplot2,
I have got a data frame (which is called data.set.y). And I would like
I have a data set that is organized in the following manner: Timestamp|A0001|A0002|A0003|A0004|B0001|B0002|B0003|B0004 ...
I have the following data: A post called Hello has categories greet Another post
Imagine I have the following data in a table called messages: message_id | language_id
We have an attribute called DateReleased for which the following Data Annotation attributes are
I have the following set of data <ids> <id1 attr1=value1 attr2=value2 /> <id2 attr3=value3
I'm using socket.io and express and have the following code: io.set('authorization', function (data, accept)
I have following PHP code for inserting session data into a table called ds_session:
I have following data to save in database using php my data is :

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.