Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retina option for ggsave #2156

Closed
hadley opened this issue Jun 13, 2017 · 6 comments
Closed

Retina option for ggsave #2156

hadley opened this issue Jun 13, 2017 · 6 comments
Labels

Comments

@hadley
Copy link
Member

@hadley hadley commented Jun 13, 2017

It would be useful to have an option to ggsave() that made it easy to produce retina quality graphics. This might be as simple as supporting dpi = "retina".

@hadley
Copy link
Member Author

@hadley hadley commented Jul 11, 2017

Perhaps it would be best to generalise to support "print", "screen", and "retina" ?

@foo-bar-baz-qux
Copy link
Contributor

@foo-bar-baz-qux foo-bar-baz-qux commented Jul 15, 2017

Sounds good to me, I had to experiment with this figure when I first started with ggplot to find a DPI I was satisfied with. This option would help save some time. I could have a go at implementing this.

I'm thinking print is 300 DPI/PPI and screen is 72 DPI/PPI per standard?

Retina is a little trickier though since it's supposed to be a resolution at which the eye cannot distinguish the individual pixels, which is dependent on viewing distance and physical screen size. The wiki article suggests 300 PPI was the initial figure for a handheld device, with the latest iPhones having 401 PPI (the highest on the list) and larger displays ~220 PPI. Would it make sense to go with the highest PPI (401)?

@hadley
Copy link
Member Author

@hadley hadley commented Jul 15, 2017

I think just doubling the dpi is standard.

@dylan-stark
Copy link
Contributor

@dylan-stark dylan-stark commented Jul 15, 2017

I agree with Hadley: the practical answer for retina is to double the available PPI (dpi for ggsave()). This is what's done in knitr and in this gist. It's also the advice in the graphic design community (ex. here).

One thing to consider is that some phones are at triple the pixel density (e.g., iPhone 6 Plus). Not sure if that warrants having "retina-2" and "retina-3". Maybe an extra "retina-plus" option? (Though the 8 is rumored to be at 3x, too.)

@foo-bar-baz-qux
Copy link
Contributor

@foo-bar-baz-qux foo-bar-baz-qux commented Jul 21, 2017

Thanks for the links, @dylan-stark they were helpful. If I'm understanding it correctly, it seems there should be 2 changes to implement this feature then:

  1. Support special dpi arguments, like screen (= 72 or 96), print (= 300), maybe mdpi (= 160) for mobile developers.
  2. A retina argument that is either FALSE (no scaling), TRUE (2x DPI). And perhaps retina-2, retina-3 for 3x and 4x DPI scaling respectively.

Compared to the gist linked, ggsave() doesn't support px inputs, so I would assume this means the user has to do the arithmetic to get the correct DP units at MDPI (160 DPI, or whichever baseline they are using) specified in inches/mm/cm. The retina scaling should then only apply to the DPI, since that will propagate to the output dimensions in pixels.

@hadley
Copy link
Member Author

@hadley hadley commented Jul 21, 2017

I think we just need more string options for dpi: screen, retina, and print.

@hadley hadley closed this in a5e2dd4 Aug 1, 2017
@lock lock bot locked as resolved and limited conversation to collaborators Jun 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants