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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T04:47:05+00:00 2026-05-29T04:47:05+00:00

I want to combine two ggplots, from two different data.frames, into one plot. Below

  • 0

I want to combine two ggplots, from two different data.frames, into one plot. Below you will find the code. I want to combine plot 1&2 or plots 3&4.

df1 <- data.frame(p=c(10,8,7,3,2,6,7,8),
             v=c(100,300,150,400,450,250,150,400))
df2 <- data.frame(p=c(10,8,6,4), v=c(150,250,350,400))

plot1 <- qplot(df1$v, df1$p)
plot2 <- qplot(df2$v, df2$p, geom="step")

plot3 <- ggplot(df1, aes(v, p)) + geom_point()
plot4 <- ggplot(df2, aes(v, p)) + geom_step()

This must be very easy to do, but somehow I can’t get it to work. Thanks for your time.

  • 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-29T04:47:07+00:00Added an answer on May 29, 2026 at 4:47 am

    As Baptiste said, you need to specify the data argument at the geom level. Either

    #df1 is the default dataset for all geoms
    (plot1 <- ggplot(df1, aes(v, p)) + 
        geom_point() +
        geom_step(data = df2)
    )
    

    or

    #No default; data explicitly specified for each geom
    (plot2 <- ggplot(NULL, aes(v, p)) + 
          geom_point(data = df1) +
          geom_step(data = df2)
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to combine these two queries into one: mysql_query(INSERT INTO categories (name, parent)
I want to combine two ArrayList into a single one. My first arraylist looks
I need to combine rows from two Excel worksheets into one long row, based
I am playing with Parsec and I want to combine two parsers into one
I want to combine two programs into a single executable. One is an open
I want to combine two .wav recording files together. Can any one help me
This question is somewhat similar to How to combine two branches from two different
In this question I managed to combine two .png images into one, and then
Imagine two positive integers A and B. I want to combine these two into
In template I have two strings which I want to combine in one. {assign

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.