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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:52:14+00:00 2026-05-25T14:52:14+00:00

I produced biplot with this R code: set.seed(12345) require(ggplot2) AData <- data.frame(Glabel=LETTERS[1:7], A=rnorm(7, mean

  • 0

I produced biplot with this R code:

set.seed(12345)
require(ggplot2)
AData <- data.frame(Glabel=LETTERS[1:7], A=rnorm(7, mean = 0, sd = 1), B=rnorm(7, mean = 0, sd = 1))
TData <- data.frame(Tlabel=LETTERS[11:20], A=rnorm(10, mean = 0, sd = 1), B=rnorm(10, mean = 0, sd = 1))
i <- 2
j <- 3
p <- ggplot(data=AData, aes(AData[, i], AData[, j])) + geom_point() + theme_bw()
p <- p + geom_text(aes(data=AData, label=Glabel), size=3, vjust=1.25, colour="black")
p <- p + geom_segment(data = TData, aes(xend = TData[ ,i], yend=TData[ ,j]),
              x=0, y=0, colour="black",
              arrow=arrow(angle=25, length=unit(0.25, "cm")))
p <- p + geom_text(data=TData, aes(x=TData[ ,i], y=TData[ ,j], label=Tlabel), size=3, vjust=1.35, colour="black")

Output
enter image description here

Everything is fine except the arrows labels. I’d like to have the labels at the end of the arrows and in the same direction as arrows. Any idea and/or solution. Thanks in advance.

  • 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-25T14:52:15+00:00Added an answer on May 25, 2026 at 2:52 pm

    Two possibilities:

    p <- p + geom_text(data=TData, aes(x=1.2*TData[ ,i], 
                                       y=1.2*TData[ ,j], 
                      label=Tlabel), size=3, vjust=0, colour="black")
    p
    #-----------------------------------
    p <- p + geom_text(data=TData, aes(x=TData[ ,i] +.1*sign(TData[ ,i]), 
                                       y=TData[ ,j]+.1*sign(TData[ ,j]), 
                      label=Tlabel), size=3, vjust=0, colour="black")
    p
    

    First one leaves labels away from the arrows a distance that varies with the “strengths” while the second one a fixed distance on the graphics plotting scale (probably the preferred solution and the one illustrated below).

    Second version as image

    And finally a fully “trigonometricized “version that will get the labels exactly in the same vector as the arrows. (The sameness of the sign(.) argument is a result of the conventions for arctangent values. Ya do what ya gatta do.) :

    p <- ggplot(data=AData, aes(AData[, i], AData[, j])) + geom_point() + theme_bw()
    p <- p + geom_text(aes(data=AData, label=Glabel), size=3, vjust=1.25, colour="black")
    p <- p + geom_segment(data = TData, aes(xend = TData[ ,i], yend=TData[ ,j]),
                  x=0, y=0, colour="black",
                  arrow=arrow(angle=25, length=unit(0.25, "cm")))
    p <- p + geom_text(data=TData, 
                aes(x=TData[ ,i] +.1*cos(atan(TData[ ,j]/TData[ ,i]))*sign(TData[ ,i]), 
                    y=TData[ ,j] +.1*sin(atan(TData[ ,j]/TData[ ,i]))*sign(TData[ ,i]), 
                label=Tlabel), size=3, vjust=0, colour="red")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I produced multiple plots using the following code: set.seed(12345) a <- data.frame(Glabel=LETTERS[1:7], A=rnorm(7, mean
Recent conversations with colleagues have produced varying points of view on this matter. What
What is a good way to render data produced by a Java process in
So we've produced a windows service to feed data to our client application and
I've produced a function to get back a random set of submissions depending on
I have a set of numbers produced using the following formula with integers 0
I have a series of data that is produced by state and information type.
Is code produced by Cython always just as correct as the Python code it
How does the value produced by rand function depends on it seed value.When we
I produced a DLL from a source project. Let's call is sourceProject.dll . This

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.