class: center, middle, inverse, title-slide # Data Visualization ## Graphics output ### Andrew Irwin,
a.irwin@dal.ca
### Math & Stats, Dalhousie University ### 2021-03-29 (updated: 2021-03-12) --- class: middle # Plan * Kinds of graphics * How to describe the size of a graphic * Knitted documents and separate files --- ### Starting figure <img src="33-graphics-output_files/figure-html/unnamed-chunk-1-1.svg" width="70%" style="display: block; margin: auto;" /> --- ### Kinds of graphics * Vector graphics (pdf, svg) * Bitmapped or raster graphics (png, jpeg) * Why does it matter? * File sizes * Quality when printed * Appearance on screen --- ### Overview * Device types: png, ragg, jpeg, svg, pdf * Size: fig.height, fig.width (in inches, default 7), and fig.asp (aspect ratio: height / width) * Display size: out.width, out.height (in percentage of display area, e.g., '70%') * Resolution: dpi (dots per inch; 96-250 on screen, 300-600 when printed) * Alignment: fig.align = left, right, center --- ### PNG example Chunk options: `fig.width = 6, fig.asp = 0.65, fig.align="center", out.width = '70%', dev = 'png'` <img src="33-graphics-output_files/figure-html/unnamed-chunk-2-1.png" width="70%" style="display: block; margin: auto;" /> --- ### Higher resolution PNG example Chunk options: `dev='png', dpi=150` <img src="33-graphics-output_files/figure-html/unnamed-chunk-3-1.png" width="70%" style="display: block; margin: auto;" /> --- ### RAGG example Chunk options: `dev='ragg_png', dpi = 150` <img src="33-graphics-output_files/figure-html/unnamed-chunk-4-1.png" width="70%" style="display: block; margin: auto;" /> --- ### JPEG example Chunk options: `dev='jpeg', dpi = 150` <img src="33-graphics-output_files/figure-html/unnamed-chunk-5-1.jpeg" width="70%" style="display: block; margin: auto;" /> --- ### SVG example Chunk options: `dev='svglite'` <img src="33-graphics-output_files/figure-html/unnamed-chunk-6-1.svg" width="70%" style="display: block; margin: auto;" /> --- ### PDF example The file looks great on [my computer](33-graphics-output_files/figure-html/pdfoutput-1.pdf) (look in `XXXX_files` folder), but is not shown properly in a web page. Chunk options: `dev='pdf'` <embed src="33-graphics-output_files/figure-html/pdfoutput-1.pdf" width="70%" style="display: block; margin: auto;" type="application/pdf" /> --- class: middle # Further reading * Course notes --- class: middle, inverse ## Task * No assigned task