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

Specify the plot dimensions in pixels? #137

Open
krassowski opened this issue Sep 11, 2020 · 2 comments
Open

Specify the plot dimensions in pixels? #137

krassowski opened this issue Sep 11, 2020 · 2 comments

Comments

@krassowski
Copy link

I would like to be able to set the size of my figure in pixels rather than inches using options()

IRkernel used to have set_plot_options() function which permitted specifying units because everything was just being passed to PNG call (https://github.com/IRkernel/IRkernel/pull/82/files#diff-d6114b524c43b90f0e7f0b24a0af9f94L10).

Currently we can only change the size using repr.plot.res, repr.plot.width and repr.plot.height. Would it be possible to add repr.plot.unit="in" so that it can be changed to "px"?

This should be pretty straightforward change and remove the inches hard-coded in:

Cairo::Cairo(width, height, tf, 'png', pointsize, bg, 'transparent', 'in', res)
else
png(tf, width, height, 'in', pointsize, bg, res, antialias = antialias)

I'm happy to create a pull request if this is change is welcome.

@flying-sheep
Copy link
Member

How about we simply allow using grid::unit objects for repr.plot.width/height?

@krassowski
Copy link
Author

No strong opinion. On one hand it could be more future-proof and flexible, on the other this would be more repetitive (if the user wanted to change both width and height) and require the user to understand what grid::unit is (which would be only problem for the very beginners, I think that R users learn about it quickly).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants