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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T13:47:30+00:00 2026-06-01T13:47:30+00:00

I started to use ggplot in order to generate some graphs. I am using

  • 0

I started to use ggplot in order to generate some graphs. I am using the very basic of the sample they have in their site for an “step graph”: http://had.co.nz/ggplot2/geom_step.html

I need something like the last example in that page. The issue I found is the example is in one DF and every Y has a different value in X. I have 3 sets to plot, all of them has the same X and Y values in all X. I don’t get how to produce the graphic in R. In excel I create the first line and add the other 2 as new data series but I am lost in ggplot. Any advise is really appreciated.

My plot commands are now as this (each of them with different df):

qplot(seq_along(x), x, data = df, geom="step", colour = trt)

Is there a way to have one df with all the values? Any example will be great. Thanks in advance for your time

EDIT>>>>

Here is some data to see:

head(df_nourbanas)
     x        trt
1    3 no urbanas
2   85 no urbanas
3  450 no urbanas
4  942 no urbanas
5 1362 no urbanas
6 1699 no urbanas

head(df_urbanas)
     x     trt
1   65 urbanas
2 1019 urbanas
3 2192 urbanas
4 3164 urbanas
5 3847 urbanas
6 4338 urbanas

head(df_todas)
     x   trt
1    3 todas
2  152 todas
3 1481 todas
4 3158 todas
5 4564 todas
6 5593 todas

And this is what I need to have (this is in excel) directly form R using the steps mode
r_steps

  • 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-01T13:47:32+00:00Added an answer on June 1, 2026 at 1:47 pm

    You are having problems because you are using implicit information in the data set: the order the points are, which becomes the x-axis position. Make this explicit and things become easier.

    df_nourbanas$idx <- seq(length=nrow(df_nourbanas))
    df_urbanas$idx <- seq(length=nrow(df_urbanas))
    df_todas$idx <- seq(length=nrow(df_todas))
    

    Now these 3 data sets can be combined.

    df_all <- rbind(df_nourbanas, df_urbanas, df_todas)
    

    and plotting them is just

    ggplot(df_all, aes(x=idx, y=x, colour=trt)) +
      geom_step()
    

    enter image description here

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

Sidebar

Related Questions

I have started to use Microsoft LogParser in order to analyse IIS logs. LogParser
I have started to use git-svn for some of my work to be able
I have just started to use Github and have been doing some tests with
I started to use IOS and the Graph Api some weeks ago. I have
I have recently started to use Eclipse after using IntelliJ for a few years.
I started to use Borland's Turbo C++ a few days ago. I actually have
I have started to use frameworks like Twitter Bootstrap , but if Twitter releases
I started to use Xcode 4.2 and i have problems with generating code coverage.
I have started to use jenkins to build my project. I build my project
I have started to use Dreamweaver CS5 for PHP coding. The PHP syntax highlighting

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.