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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:37:00+00:00 2026-05-27T07:37:00+00:00

I have stacked into the question: I need to plot the image with DPI=1200

  • 0

I have stacked into the question: I need to plot the image with DPI=1200 and specific print size.

By default the png looks ok…
enter image description here

png("test.png",width=3.25,height=3.25,units="in",res=1200)
par(mar=c(5,5,2,2),xaxs = "i",yaxs = "i",cex.axis=1.3,cex.lab=1.4)
plot(perf,avg="vertical",spread.estimate="stddev",col="black",lty=3, lwd=3)
dev.off()

But when I apply this code, the image became really terrible it’s not scaling (fit) to the size that is needed. What did I miss? How to “fit” the image to the plot?

enter image description here,

  • 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-27T07:37:01+00:00Added an answer on May 27, 2026 at 7:37 am

    A reproducible example:

    the_plot <- function()
    {
      x <- seq(0, 1, length.out = 100)
      y <- pbeta(x, 1, 10)
      plot(
        x,
        y,
        xlab = "False Positive Rate",
        ylab = "Average true positive rate",
        type = "l"
      )
    }
    

    James’s suggestion of using pointsize, in combination with the various cex parameters, can produce reasonable results.

    png(
      "test.png",
      width     = 3.25,
      height    = 3.25,
      units     = "in",
      res       = 1200,
      pointsize = 4
    )
    par(
      mar      = c(5, 5, 2, 2),
      xaxs     = "i",
      yaxs     = "i",
      cex.axis = 2,
      cex.lab  = 2
    )
    the_plot()
    dev.off()
    

    Of course the better solution is to abandon this fiddling with base graphics and use a system that will handle the resolution scaling for you. For example,

    library(ggplot2)
    
    ggplot_alternative <- function()
    {
      the_data <- data.frame(
        x <- seq(0, 1, length.out = 100),
        y = pbeta(x, 1, 10)
      )
    
    ggplot(the_data, aes(x, y)) +
        geom_line() +
        xlab("False Positive Rate") +
        ylab("Average true positive rate") +
        coord_cartesian(0:1, 0:1)
    }
    
    ggsave(
      "ggtest.png",
      ggplot_alternative(),
      width = 3.25,
      height = 3.25,
      dpi = 1200
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 2 Divs stacked on top of each other. I need a really
I have three elements stacked into each other. Now I want the innermost element
I have two labels that are stacked. If I want a horizontal line between
I have a form that will multiple Panel controls stacked on top of each
Similar question from last night, I don't have access to edit the source HTML
I have run into another problem with my current project. I have a form
I have a stacked sequence which runs 2 different tests continuously. Lets call them
I currently have a bunch of inline-block div s stacked up horizontally. When the
I have two horizontally scrolling UIScrollViews stacked vertically on top of each other within
I have two divs stacked one above the other, with my code expanding 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.