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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T00:36:29+00:00 2026-06-15T00:36:29+00:00

Currently, my code initially lets the user select what dataset they want (A choice

  • 0

Currently, my code initially lets the user select what dataset they want (A choice of two). Then based on what they choose, other plotting variables for the datasets’ respective subsets appear. This works fine, apart from the fact that I would like the plots to be overlain all on one plot, instead of separately as they appear by default.

I have a default plot, plot_Total, and the other options in the datasets are looking at particular subsets of this. So it would make sense to have just one scatter.

 output$plot_Total <- reactivePlot(function() { 
  plot.new()
   plot.window(xlim=c(1850,2020), ylim = c(0,5000000))
   axis(1)
   axis(2)
   title(main="Numbers over the years")
   title(xlab="Year")
   title(ylab="Number of people")
   box()
   points(dat$Year, dat$Total, col="red")
   lines(dat$Year, dat$Total, col="red")
   })

 output$plot_subset1 <- reactivePlot(function() { lines(dat$Year, dat$subset1) })
 output$plot_subset2 <- reactivePlot(function() { lines(dat$Year, dat$subset2) })

why doesnt this code snippet work? It just creates blank spaces for each (unwanted) graph, underneath which it says “Error: plot.new has not been called yet”. How do I specify to add these lines to the default (plot_Total) plot?

  • 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-15T00:36:31+00:00Added an answer on June 15, 2026 at 12:36 am

    Update: By playing around with the code for the graph on the shiny homepage, I realised that I had to do this:

     output$plot_Total <- reactivePlot(function() { 
      plot.new()
       plot.window(xlim=c(1850,2020), ylim = c(0,5000000))
       axis(1)
       axis(2)
       title(main="Numbers over the years")
       title(xlab="Year")
       title(ylab="Number of people")
       box()
       points(dat$Year, dat$Total, col="red")
       lines(dat$Year, dat$Total, col="red")
      if (input$RC) {   lines(dat$Year, dat$dat)}
      })
    

    This differs from my original code in two ways. Firstly, the conditional is added as just one line within the same reactiveplot function. Secondly, I created a new data.frame which only contains the subset RC. This was initially not working as input$dat$RC, but when RC is a dataframe of its own it works as input$RC.

    Points to Chase for steering me in the right direction!

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

Sidebar

Related Questions

I am currently working with a code example that initially is designed to take
Currently this code generates a colored hyperlink to an ad listing on my site.
Currently my code below works fine but it's a bit of overkill. In my
Currently my code loads a TabWidget with 4 tabs. The first tab points to
Currently our code uses a for-loop for filling a buffer holding a Unicode string
My code currently looks like this: private Foo myFoo; public Foo CurrentFoo { get
My code currently looks like this: <div style=position: fixed; width: 35.25%; height: 6.75%; left:
I currently have code that does the following: private final static ExecutorService pool =
I currently have code in objective C that can pull out an integer's most
I am currently writing code in C++ to find all possible permutations of 6

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.