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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:59:58+00:00 2026-06-11T19:59:58+00:00

I create a figure containing two plots using a function i.e. data1<-1:3 basic<-function(data1){ par(mfrow=c(2,1))

  • 0

I create a figure containing two plots using a function i.e.

data1<-1:3

basic<-function(data1){
par(mfrow=c(2,1))
plot(data1)
plot(data1)
}

basic(data1)

Now I want to add text to the plots without having to include it in the function. But I can only add text to the bottom plot (see below).

text(x=c(1.5,1.6,1.7),y=c(2,2.1,2.2), labels=c("X","Y","Z"))

enter image description here

How can I add text to the top plot outside of the function? (I have lots of figures I create using the same function but need to place slightly different text labels in slightly different positions on each one). Thanks for any advice.

  • 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-11T20:00:00+00:00Added an answer on June 11, 2026 at 8:00 pm

    You could outline what the different texts are first e.g.

    data1<-1:3
    
    text1 <- data.frame(x=c(1.5,1.6,1.7),y=c(2,2.1,2.2), labels=c("X","Y","Z"))
    text2 <- data.frame(x=c(2,2.9,1.0),y=c(2,2.1,2.2), labels=c("X","Y","Z"))
    

    then put them in your function

    basic<-function(data1){
    par(mfrow=c(2,1))
    plot(data1)
    text(text1)
    plot(data1)
    text(text2)
    }
    
    basic(data1)
    

    As @Andrie says calling plot means any further text() calls will work on the last plot only

    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 am currently trying to create a graph using AChartEngine containing two y-axis (one
Given an array containing other nested arrays, I want to create an array containing
I have two mysql tables: Item containing items that one can buy: CREATE TABLE
I'm attempting to create a complex div structure using CSS. I want it to
I am looking for a way to create figure that contains several subplots which
I cannot figure out why the following simple program doesn't (create) and then write
I am trying to figure out how to create a temporary table that is
I am trying to figure out how to create an image gallery like the
I'm trying to figure out how to create a http CRAN-repository. I've tried to
I'm trying to figure out the best way to create a row of three

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.