Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rpresentation in Rstudio - Make image fill out the whole screen

Making an Rpresentation in Rstudio with knitr I have a slide with just one picture, which I want to fill out the whole screen/slide. How do I do that?

The second slide of the following .Rpres-document is set to 2000x2000 pixels but it still only fills a small area of the screen:

first slide
======


Slide with plot which I want to fill the whole screen
========================================================
title: false
```{r, echo=FALSE,out.height="2000px",out.width="2000px"}
plot(cars)
```

This is what I mean when I write that the picture does not "fill the whole screen", the red lines are drawn at parts of the screen which are not filled by the plot.

enter image description here

update november 2016

Choosing "HTML Slidy" when creating a new presentation in Rstudio Version 1.0.44, gives me easier control of the size. The following is close to what i wanted on a full HD resolution, and very simple to do:

---
title: "Untitled"
output: slidy_presentation
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```

## 

```{r pressure, fig.height=10, fig.width=19}
plot(pressure)
```
like image 287
Rasmus Larsen Avatar asked May 12 '14 21:05

Rasmus Larsen


People also ask

How do I embed an image in R markdown?

To add an image in markdown you must stop text editing, and you do this with the command [Alt text] precedeed by a ! Then you have to add the path to the image in brackets. The path to the image is the path from your directory to the image.

How do I make a slideshow in R?

To create a new R Presentation you execute the New File -> R Presentation command: After specifying the location to save the presentation, a new presentation will be created and a preview will show within the Presentation tab in the upper right corner of the IDE.

How do I make my plot bigger in RMarkdown?

For a plot of different size, change simple the numbers: {r fig2, fig. height = 3, fig. width = 3, fig. align = "center"} .


Video Answer


3 Answers

Here's the way to set the overall presentation size: http://www.rstudio.com/ide/docs/presentations/displaying_and_distributing_presentations The default is quite small: 960 * 700.

The interaction between the figure sizes, output sizes, and presentation sizes is tricky and I'm not an expert, but this seems to work ok. After some messing around, this looked alright:

first slide
======
width: 1920
height: 1080

Slide with plot which I want to fill the whole screen
========================================================
title: false
```{r myplot,echo=FALSE,fig.width=8,fig.height=4.5,dpi=300,out.width="1920px",out.height="1080px"}
plot(cars)
```
like image 153
oropendola Avatar answered Oct 22 '22 15:10

oropendola


You can find your screen size and use that to set the plot size using grDevices a = dev.size("px")

and then you can use that in your code.

like image 1
Thanushan Avatar answered Oct 22 '22 17:10

Thanushan


knitr version: 1.16

RStudio version: 1.0.143

problem description: when knitr parses the R code, even if you set a custom css page width, the output an html file has a constant max-width: 940px;

knitr output :

max-width: 940px;

My css setting file

max-width: 2000px;

min-width: 700px;

knitr does recognise the custom css file, but it does not create an output according to my css settings. I know this because When I deliberately misspell the css file, knitr produces an error during output.

The solution that worked for me was to go to the file created by knitr and change by hand the max-width: 2000px; min-width: 700px;

Better solution would be of course to find the root of the problem in the knitr /pandoc program

like image 1
Andy Paparountas Avatar answered Oct 22 '22 17:10

Andy Paparountas