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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T03:05:57+00:00 2026-05-30T03:05:57+00:00

I set up a nice plot with a transparent superimposed scatterplot on a png

  • 0

I set up a nice plot with a transparent superimposed scatterplot on a png image file. I want my plot window and my pdf output to be of the exact same size as my png- 962×745.

However, even after turning off axes, annotations and frames, R still leaves a border around the image.

This can be shown with an easy example: This plot shows two dots, which should be at the outermost ends of the plot. But they aren’t:

plot(rbind(c(1,745),c(962,1)),bty ="n",axes=F,frame.plot=F, xaxt='n', ann=FALSE, yaxt='n', asp=745/962)

And together with the PDF device:

pdf(width=10.02,height=7.76)
par(mar=rep(0, 4),mai=rep(0, 4), xpd = NA) 
plot(rbind(c(1,745),c(962,1)),bty ="n",axes=F,frame.plot=F, xaxt='n', ann=FALSE, yaxt='n', asp=745/962)
dev.off()
  • 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-30T03:05:58+00:00Added an answer on May 30, 2026 at 3:05 am

    You could also use grid graphics to avoid those default axes, etc.

    library(jpeg)
    library(grid)
    
    d = data.frame(x=rnorm(100, 10), y=rnorm(100, -100))
    utils::download.file("http://i.imgur.com/5MexD.jpg", "img.jpg")
    img = readJPEG("img.jpg")
    
    
    w <- convertUnit(unit(ncol(img),"pt"), "in", value=TRUE)
    h <- convertUnit(unit(nrow(img),"pt"), "in", value=TRUE)
    
    dev.new(width=w, height=h)    
    grid.raster(img, width=unit(1,"npc"), height=unit(1,"npc"))
    
     v = dataViewport(xData=d$x, yData=d$y)
     grid.points(d$x,d$y, default.units="native", vp=v, 
                 gp=gpar(col="white"), pch=8)
    

    enter image description here

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

Sidebar

Related Questions

Delphi 2010 has a nice set of new file access functions in IOUtils.pas (I
I am looking for a set of nice plugins to use when developing software.
I used once a very nice emacs function that set all my windows (emacs
This .aspx page has a very nice set of collapsible sections with little +
I know recently Spring 3.0 was released which brought about a nice new set
I'm currently trying to set up a nice back button contextual menu for my
I've following data: I want to plot a graph shows for all x the
I have a toolTip set up to display nice title tags to the user
Okay so I've set up and tested a nice little WCF service. The client
I found Core Plot as very nice plotting library. But there is small issue:

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.