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

[feature request] vector of fig.width and fig.height #538

Closed
baptiste opened this issue May 21, 2013 · 6 comments
Closed

[feature request] vector of fig.width and fig.height #538

baptiste opened this issue May 21, 2013 · 6 comments
Labels
feature Feature requests
Milestone

Comments

@baptiste
Copy link

I'm setting dev = c('pdf', 'png') to produce a markdown report that will get converted with Pandoc into both html and pdf (via latex). Since both formats have quite a different purpose -- latex pdf is good for print documents, html for online viewing, I would like to specify a different figure size for either device, which is currently not possible (scalar fig.width). The idea is that a html page seen in a web browser can easily accommodate a 12 inches wide figure, but this large width will currently shrink the font size when fitted into the latex version, which should therefore be limited to 8 inches, say.

@yihui
Copy link
Owner

yihui commented May 23, 2013

Actually this is a little bit tricky. In certain cases, a plot can be distorted if you save it to different sizes.

Besides, I have to open one (and only one) device before drawing plots, and only one set of fig.width and fig.width can be used for this device. If you provide vectors, I'm not sure which elements I should use.

Anyway, I'll think about it.

You can also consider other approaches, e.g.

HTML_VERSION = TRUE
fs = function(size) {
  if (HTML_VERSION) 1.5 * size else size
}
opts_chunk$set(dev = if (HTML_VERSION) 'png' else 'pdf')
```{r fig.width=fs(7), fig.height=fs(5)}
```

Then you can control the device and fig.width/fig.height using a single variable HTML_VERSION.

@baptiste
Copy link
Author

I see how it's hard to implement, but it does offer benefits: one doesn't have to run the document twice to get both versions of the plots, which can be a good time-saver. Thanks for considering it anyway!

@yihui
Copy link
Owner

yihui commented Jun 5, 2013

It is not hard to implement at all, and I think I will do it.

@baptiste
Copy link
Author

baptiste commented Jun 6, 2013

Great, thanks!

yihui added a commit that referenced this issue Jun 7, 2013
@yihui yihui closed this as completed in 20191a6 Jun 7, 2013
@yihui
Copy link
Owner

yihui commented Jun 7, 2013

Done.

yihui added a commit that referenced this issue Oct 12, 2016
@github-actions
Copy link

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature Feature requests
Projects
None yet
Development

No branches or pull requests

2 participants