I'm posting it because I'm experiencing a weird behavior with the built-in RStudio function "Save as image". When I save an image and set the width and height parameters, the final plot is larger. I have been using this option a long time ago but this misfunctioning appeared suddenly.
For instance, I set a size of 3500 x 1500 px but the final image is 4812 x 2062 px:
I have no solution for you, but I can confirm that something is off. The number of pixels in the png files that I save is 2.5 times larger than what I specified. For example: Width:1000 x Height:1000 becomes 2500x2500 at 240ppi.
I get the correct number of pixels when I save an image, using the same versions of R and RStudio that you do. It might help to know your operating system and what graphics driver you have selected (Tools > Global Options... > General > Graphics, both graphics device settings).
It makes no difference what Graphics device I select: (Default), Quartz, Cairo, CairoPNG or AGG or If I have Antialiasing set to Default, None, Gray or subpixel in Tools > Global Options > Graphics. All images have 2.5 x as many pixels as I specified in Width And Height. Update Preview makes no difference.
RStudio.Version()$version
[1] ‘2024.4.1.748’
R version 4.4.0 (2024-04-24)
Platform: aarch64-apple-darwin20
Running under: macOS Sonoma 14.4.1
I found on this GitHub thread that after 2015 the default dpi in RStudio was set to 96 dpi. However, in the most recent versions, it might have changed again. I downgraded to RStudio 2023.09.0 Build 463 and the figures are being exported in the same size the user defined. However, I didn't find anything related to a change in the default export dpi in the RStudio change-log.