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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:53:41+00:00 2026-05-25T18:53:41+00:00

I produced multiple plots using the following code: set.seed(12345) a <- data.frame(Glabel=LETTERS[1:7], A=rnorm(7, mean

  • 0

I produced multiple plots using the following code:

set.seed(12345)
a <- data.frame(Glabel=LETTERS[1:7],   A=rnorm(7, mean = 0, sd = 1),  B=rnorm(7, mean = 0, sd = 1),  C=rnorm(7, mean = 0, sd = 1))
T <- data.frame(Tlabel=LETTERS[11:20], A=rnorm(10, mean = 0, sd = 1), B=rnorm(10, mean = 0, sd = 1), C=rnorm(10, mean = 0, sd = 1))


 for(i in 2:(ncol(a)-1))
  {
    for(j in (i+1):ncol(a))
    {
      r <- 0.08
      win.graph(width=10, height=10, pointsize=12)
      plot(a[, i],a[, j], pch=19, cex=1, panel.first=grid(col="gray", lty="dotted"))
      points(T[, i],T[, j],pch=19, col="white", cex=1)
      text(a[, i],a[, j], rownames(a), cex=1,col="black", pos=1)
      text(T[, i],T[, j], rownames(T), cex=1,col="blue",  pos=1)
      arrows(x0=0, y0=0, x1=T[, i], y1=T[, j], length=0.1,col=2,lty=1)
    }
  }

Using win.graph I can maintain all plots in base. But I’d like to have my plot in ggplot2. Following is my code ggplot2.

library(ggplot2)
 for(i in 2:(ncol(a)-1))
  {
    for(j in (i+1):ncol(a))
    {
      r <- 0.08
      p <- ggplot(data=a, mapping=aes(x=a[, i], y=a[, j])) + geom_point() + theme_bw()
      p <- p + geom_text(data=a, mapping=aes(x=a[, i], y=a[, j], label=Glabel),
                     size=3, vjust=1.35, colour="black")
      p <- p + geom_segment(data = T, aes(xend = T[ ,i], yend=T[ ,j]),
                        x=0, y=0, colour="black",
                        arrow=arrow(angle=25, length=unit(0.25, "cm")))
      p <- p + geom_text(data=T, aes(x=T[ ,i], y=T[ ,j], label=Tlabel), size=3, vjust=0, colour="red")
      print(p)
    }
  }

The above code gives me the last graph only. I wonder how can I get all possible graphs in ggplot2. Thanks

  • 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-25T18:53:42+00:00Added an answer on May 25, 2026 at 6:53 pm

    From @baptiste’s comment:

    library(ggplot2)
    for(i in 2:(ncol(a)-1))
    {
     for(j in (i+1):ncol(a))
     {
      r <- 0.08
      p <- ggplot(data=a, mapping=aes(x=a[, i], y=a[, j])) + geom_point() + theme_bw()
      p <- p + geom_text(data=a, mapping=aes(x=a[, i], y=a[, j], label=Glabel),
                     size=3, vjust=1.35, colour="black")
      p <- p + geom_segment(data = T, aes(xend = T[ ,i], yend=T[ ,j]),
                        x=0, y=0, colour="black",
                        arrow=arrow(angle=25, length=unit(0.25, "cm")))
      p <- p + geom_text(data=T, aes(x=T[ ,i], y=T[ ,j], label=Tlabel), size=3, vjust=0, colour="red")
    dev.new()
      print(p)
    }
    
    
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following piece of code (that may be invoked multiple times or
Please help! I need to produce a Crystal Report with multiple data columns, but
I've produced a python egg using setuptools and would like to access it's metadata
I'm working on a project that uses multiple libraries, set up in a structure
I am writing a piece of code to read in several GB of data
I need to export multiple data tables to Excel on the clients machine, each
I have created a 3d map using rgl.surface(), mainly following Shane's answer in this
I have an array (produced by uploading multiple files) that returns this: Array (
I have to produce multiple reports on a regular basis; same reports are produced
The requirements are : Fact 1 : We have some data files produced by

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.