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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T15:17:04+00:00 2026-06-03T15:17:04+00:00

How can I programmatically capture the X coordinate of letter r in better string

  • 0

How can I programmatically capture the X coordinate of letter “r” in “better” string in the example? I’d like to capture that coordinate in order to dynamically draw the arrow next to it. Can this be done in R? It can be done in SAS …with some difficulty.

x<-c(1,3)
y<-c(3,3)
plot(y~x, type="c", ylim=c(-1,5), xlim=c(-3,3), col="red") 
abline(h=0,v=0, lty=3)
text(0.3, -2.5, xpd=T, "Group 1 better", adj=0)

#manually draw the arrow
arrows(x0=1.3, x1=3, y0=-2.5, y1=-2.5, length=0.1, code=2,xpd=T)

enter image description here

The obvious approach is to count number of letters in the string and add that number to the X coordinate of the string. This approach will probably work well in most cases but may not work well in if the size/style,angle of the text changes. I am wondering if there is a an easy way to capture the last position of the string.
SAS does it by placing the arrow relative to the internal coordinates of the previous string.

I would also like to know how to capture the last coordinate of any other graphical element as well – if possible at all.
Thank you

  • 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-03T15:17:05+00:00Added an answer on June 3, 2026 at 3:17 pm

    Use strwidth to get the string width, and add an extra character’s width for a bit of space:

    > arrowlabel = "Group 1 better")
    > sw = strwidth(arrowlabel)
    > xpos = 0.3 + sw + sw/nchar(arrowlabel)
    

    Then draw your arrow starting at x=xpos.

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

Sidebar

Related Questions

I'd like to use the following in UIBinder, so that I can programmatically set
How can I programmatically determine sites of a SharePoint 2007 installation that use custom
How can I programmatically get the phone number of the device that is running
we can easily capture a view(screenshot) programmatically in iPhone. But i am trying to
I know that jQuery can programmatically trigger events on DOM elements that are listening
Is there a way that I can Programmatically set an Expires Header in code
Is there any way that I can programmatically create (and I guess access) hidden
Is there a way that I can programmatically figure out whether a particular file
I know that I can programmatically upgrade to the latest version of the running
I looked at several related answers, and determined that I can programmatically clear the

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.