-
Notifications
You must be signed in to change notification settings - Fork 326
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
how to set width and height of matplotlib images in python Rmd chunks? #1140
Comments
Also would it be possible to output PNG instead of PDF? Slides with PDF/vector graphics take up a lot of disk space (>10MB) so it would be nice to be able to switch to PNG graphics to reduce slide file size. hook <- getOption("reticulate.engine.matplotlib.show", eng_python_matplotlib_show) |
You could use the So where you have:
replace with, eg.
|
Yes. You can do so using the title: "matplotlib test"
author: "Toby Dylan Hocking"
output:
beamer_presentation:
dev: png |
Great, thanks for the advice. Going forward for other people who have these kinds of questions, can these tips please be documented in some obvious place? For example,
For the record I was trying to get this to work with plotnine so the final code I used looks like this,
|
The standard knitr chunk options
|
Thanks! I confirm this works with these recent R/package versions
|
hi thanks very much for this package which is very useful for including python chunks in Rmd documents.
Is there a way to control the height and width of the images produced in the chunks? I would like to make Rmd beamer slides with images from matplotlib which have reduced height, but full slide width (so you can write a few lines of commentary above/below the figure).
The fig.width and fig.height have no effect on the image size, and that is documented as R-specific: https://bookdown.org/yihui/rmarkdown-cookbook/figure-size.html says The size of plots made in R can be controlled by the chunk option fig.width and fig.height (in inches).
Is there another way to control matplotlib figure height and width?
The out.height='25%' chunk option works for proportionally reducing the image size (both height and width), but I would like to reduce the height but maintain full width. is that possible?
Thanks and here is a zip file with MRE as Rmd source code with rendered PDF.
slides.zip
The text was updated successfully, but these errors were encountered: