Weird behavior with RStudio "Save as image" function

Hi there!

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:

Any idea on whats going on and how to solve it?

Regards.

P.D.: I'm running R 4.4.0 and RStudio 2024.04.1 Build 748. I tried downgrading both but is not working.

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 wonder if it's related to the operating system. I'm on Linux Mint, and I don't have this problem.

The best place to raise issues with the IDE software is the github for it :
Issues · rstudio/rstudio (github.com)

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.

Issue (for reference): Weird behavior with RStudio "Save as image" function · Issue #14727 · rstudio/rstudio · GitHub

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.