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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T04:15:58+00:00 2026-05-24T04:15:58+00:00

I have a set of coordinates (x, y) = (0, 2), (1, 3), (1,

  • 0

I have a set of coordinates

(x, y) = (0, 2), (1, 3), (1, 2), (2, 4)      (this is a simplified example)

Whenever there is an increase in the y-ordinate, I would like to join the coordinates by a continuous line. Whenever there is a decrease in the y-ordinate, I would like to join the coordinates by a dashed line. In the example above,

1.) the coordinates (0, 2) and (1, 3) are joined by a straight line,

2.) the coordinates (1, 3) and (1, 2) are joined by a dashed line, and

3.) the coordinates (1, 3) and (2, 4) are joined by a straight line.

Is it possible to do this using ggplot in R? So far, I could only have a continuous line joining the coordinates. (If this possibly makes anything easier, I only have a decrease in the y-ordinate when there is no change in the x-ordinate.)

Thank You for your help!

  • 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-24T04:15:59+00:00Added an answer on May 24, 2026 at 4:15 am

    try this,

    dat <- data.frame(x=c(0,1,1,2),y=c(2,3,2,4))
    
    ## add endpoints (xend, yend), and and id variable 
    ## tracking the sign of diff(y)
    dat2 <- with(dat, data.frame(x=x[-length(x)], y=y[-length(y)],
                                 id= diff(y) > 0,xend=x[-1], yend=y[-1]))
    
    head(dat2)
    ggplot(dat2) +
      geom_segment(aes(x=x, y=y, xend=xend, yend=yend, linetype=id)) +
      scale_linetype_manual(values=c("dashed", "solid"))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a set of coordinates. I would like to take, for instance, the
I have an application where I would like to get the volume coordinates from
I have a transformation set up in Opengl like this: glPushMatrix(); glTranslated(pntPos.X(), pntPos.Y(), pntPos.Z());
I have a large file (~100k strokes) with points like (Y,X), where coordinates set
I have a set of geo coordinates and I'd like to build a URL
Assuming I have a large set of Coordinates such us (3,4) , (5,-6) ,
I have set a background on the data-role=page element like so <div data-role=page style=background:
I have set up Eclipse Indigo to do line debugging with CFEclipse over port
The basic idea is very easy. Simplified you could say... a snake like line
I have an array to store a set of coordinates for painting a piece

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.