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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T15:59:02+00:00 2026-05-30T15:59:02+00:00

I have seen a few questions on here (one was even by me) with

  • 0

I have seen a few questions on here (one was even by me) with respect to using R to plot an image.

The difference here is that I need to set the reference cooridnates for my image to match the data I am looking to plot on top of the image.

More specifically, I need R to understand that the coordinates for the background image are x = (-100,100) and y = (40,-40).

I have been able to to read in the image file and plot it using the ReadImages package, but when I overlay my data using points(), the data obviously do not line up appropriately.

Any help is much appreciated.

EDIT: here are some example data and I attached the imageenter image description here:

structure(list(teamid = c("6", "6", "6", "6", "6", "6", "2", 
"6", "6", "6", "2", "6", "10", "10", "10", "10", "20", "20", 
"10", "10", "10", "20", "20", "20", "10", "10"), xcoord = c("79", 
"81", "33", "34", "75", "52", "-67", "80", "44", "79", "-53", 
"54", "-55", "-81", "-66", "-66", "45", "81", "-78", "-70", "-59", 
"50", "53", "63", "-79", "-78"), ycoord = c("0", "0", "-18", 
"-20", "6", "-11", "-7", "7", "-28", "-10", "35", "22", "25", 
"-5", "25", "23", "-11", "13", "22", "16", "13", "23", "7", "16", 
"8", "8")), .Names = c("teamid", "xcoord", "ycoord"), class = "data.frame", row.names = c(74328L, 
74331L, 74332L, 74334L, 74336L, 74338L, 74340L, 74341L, 74346L, 
74347L, 74348L, 74349L, 100136L, 100137L, 100138L, 100139L, 100147L, 
100148L, 100151L, 100154L, 100156L, 100158L, 100159L, 100161L, 
100163L, 100167L))
  • 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-30T15:59:04+00:00Added an answer on May 30, 2026 at 3:59 pm

    You can create an empty plot with the correct dimensions, then use the rasterImage function to plot the image, then adding the points should work fine.

    Another approach is to use the updateusr function from the TeachingDemos package after plotting the image to make sure that the coordinates match what you want them to before adding lines or points.

    I saved your graphic above as ice.png and ran the following code:

    library(EBImage)
    ice <- readImage('My Pictures/ice.png')
    pos <- structure(list(teamid = c("6", "6", "6", "6", "6", "6", "2",
      "6", "6", "6", "2", "6", "10", "10", "10", "10", "20", "20",
      "10", "10", "10", "20", "20", "20", "10", "10"), xcoord = c("79",
      "81", "33", "34", "75", "52", "-67", "80", "44", "79", "-53",
      "54", "-55", "-81", "-66", "-66", "45", "81", "-78", "-70", "-59",
      "50", "53", "63", "-79", "-78"), ycoord = c("0", "0", "-18",
      "-20", "6", "-11", "-7", "7", "-28", "-10", "35", "22", "25",
      "-5", "25", "23", "-11", "13", "22", "16", "13", "23", "7", "16",
      "8", "8")), .Names = c("teamid", "xcoord", "ycoord"),
     class = "data.frame", row.names = c(74328L,
      74331L, 74332L, 74334L, 74336L, 74338L, 74340L, 74341L, 74346L,
      74347L, 74348L, 74349L, 100136L, 100137L, 100138L, 100139L, 100147L,
      100148L, 100151L, 100154L, 100156L, 100158L, 100159L, 100161L,
      100163L, 100167L)) 
    pos$xcoord <- as.numeric(pos$xcoord)
    pos$ycoord <- as.numeric(pos$ycoord)
    
    ice2 <- as.raster(ice)
    
    pin <- par('pin')
    plot( c(-100,100), c(-40,40), type='n', xlab='', ylab='', 
        asp=pin[1]/pin[2], axes=FALSE, xaxs='i', yaxs='i')
    rasterImage(ice2, -100, -40, 100, 40, interpolate=FALSE)
    with(pos, text(xcoord, ycoord, teamid, col='green', cex=1.2) )
    

    Does this do what you want?

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

Sidebar

Related Questions

I've seen a couple of questions over the last few days that have used
I have seen a few times people using -1 as opposed to 0 when
I have seen a few posts regarding this issue but not one specific to
I have seen a few OSX apps that have a Special Characters menu item
If you've seen my last few questions you'd know by now that I've been
I've seen a few other questions dealing with localization but that doesn't seem to
I've seen a few questions here related to determining the similarity of files, but
Summary I have seen a few questions on std::vector recently, and out of curiosity
I've seen a few similar questions on SO but nothing that seems to actually
I have seen quite a few questions about this but cant seem to find

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.