Plot options

Reportistica con R Markdown

Amy Peterson

Head of Core Curriculum at DataCamp

Figure dimensions

  • fig.width
  • fig.height
Reportistica con R Markdown

Figure dimensions

Code to set 5 by 3 figure dimensions using fig.width and fig.height

Knit document with 5 by 3 figure dimensions using fig.width and fig.height

Reportistica con R Markdown

Figure dimensions

Code to set 5 by 3 figure dimensions using fig.dim

Knit document with 5 by 3 figure dimensions using fig.dim

Reportistica con R Markdown

Output dimensions

  • out.width
  • out.height
Reportistica con R Markdown

Output dimensions

Code to set output dimensions at 50 percent using out.width

Knit document with 50 percent output dimensions using out.width

Reportistica con R Markdown

Figure alignment

  • fig.align
    • 'left'
    • 'right'
    • 'center'
Reportistica con R Markdown

Figure alignment

Code to set left figure alignment using fig.align

Knit document with left figure alignment using fig.align

Reportistica con R Markdown

Local vs. global options

Setting figure alignment locally in individual code chunks

Setting figure alignment globally in the setup code chunk

Reportistica con R Markdown

Setting options globally

Setting left figure alignment globally in the setup code chunk

Knit document with global left figure alignment

Reportistica con R Markdown

Adding captions

Adding figure caption with fig.cap

Knit document with plot and figure caption

Reportistica con R Markdown

Let's practice!

Reportistica con R Markdown

Preparing Video For Download...