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

  • SEARCH
  • Home
  • 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 7429575
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T08:59:27+00:00 2026-05-29T08:59:27+00:00

How do I make the following plot in R? I have a file of

  • 0

How do I make the following plot in R?

I have a file of the format:

0 2 5 911.2
0 4 10 842.59
1 6 15 813.23
1 8 20 823.23
1 2 15 813.31
0 4 5 844.59
0 6 25 854.54

The first column can be 0 or 1 only. The second column can be 2, 4, 6, 8 or 1. The third column is an integer. The fourth column is a double.

I want to create a plot such that that the X axis is the third column, the Y axis is the fourth column, the color designates the number in the second column (with maybe going from green to red in a cold-hot color scheme) and the shape (let’s say triangle versus circle) tells whether the first column is 1 or 0. I would also like a legend for all of this (the color and the shape of the points).

Any ideas?

I know how to create the matrix, so you can assume that I have a file loaded as a matrix there.

Thanks.

  • 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-29T08:59:28+00:00Added an answer on May 29, 2026 at 8:59 am

    Give this a go.

    ## Run only the first time
    install.packages("ggplot2")
    
    ## Change to data.frame
    mydf <- as.data.frame(yourMatrix)
    names(mydf) <- c("c1", "c2", "c3", "c4")
    require(ggplot2)
    qplot(x = c3, y = c4, color = c2, shape = as.factor(c1), data = mydf)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can someone help me figure out the following make file? BINS=file1 file2 file3 all:
Can someone tell me how I can make the following output? I have a
How do I make the following url forbidden in apache; main/index.php?site=ing I have tried
ModelMultipleChoiceField doesn't select initial choices and I can't make the following fix (link below)
If I have the following: {hdrs: [Make,Model,Year], data : [ {Make:Honda,Model:Accord,Year:2008} {Make:Toyota,Model:Corolla,Year:2008} {Make:Honda,Model:Pilot,Year:2008}] }
I can't seem to make Xcode find the Core Plot header. I've done the
I am trying to make a contour plot of the following data using matplotlib
I have been trying to find ways to make the following piece of code
I have the following lines to render TeX annotations in my matplotlib plot: import
I try to make following: Horizontal list of images, that I can select and

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.