Overview of R and ggplot2 for graphics

Slides:



Advertisements
Similar presentations
2.01 Investigate graphic image design. Image Resolution.
Advertisements

Introduction to Computer Graphics Raster Vs. Vector COMMUNICATION TECHNOLOGY.
Graphics CS 121 Concepts of Computing II. What is a graphic? n A rectangular image. n Stored in a file of its own, or … … embedded in another data file.
2.01 Understand Digital Raster Graphics
Introduction to Computer Graphics
The University of Adelaide Picture Perfect: Image Formats and Resolution Peter Murdoch March 2014 PREPARING GOOD LOOKING DOCUMENTS.
Raster vs Vector and Image Resolution By Josh Gallagan.
Components Text Text--Processing Software A Word Processor is a software application that provides the user with the tools to create and edit text.
Part A Multimedia Production Rico Yu. Part A Multimedia Production Ch.1 Text Ch.2 Graphics Ch.3 Sound Ch.4 Animations Ch.5 Video.
Minard Saladino By:. Introduction: Illustrator is a vector-based imaging program. Unlike PhotoShop, which deals in pixels (raster images), this one deals.
Prepared by George Holt Digital Photography BITMAP GRAPHIC ESSENTIALS.
Dean Pentcheff NHMLAC MBPC/Crustacea 17 April 2006.
COMP Bitmapped and Vector Graphics Pages Using Qwizdom.
Lecture 4 - Introduction to Computer Graphics
 Scaling an image is resizing the image in a graphic editing software so it is the proper size before adding it to a site.  Important NOTE: If you insert.
SBEC Master Technology Teacher Competency 5 Marie L. Evans EDTC 6342 Janice Butler.
8 Using Web Graphics Section 8.1 Identify types of graphics Identify and compare graphic formats Describe compression schemes Section 8.2 Identify image.
2.01D Investigate graphic image design. Image Resolution.
Digital File Formats ACCT-IGD-10: Students will generate and manipulate various graphic imaging processes. ACCT-IGD-15: Students will identify and produce.
Section 8.1 Create a custom theme Design a color scheme Use shared borders Section 8.2 Identify types of graphics Identify and compare graphic formats.
Digital Multimedia, 2nd edition Nigel Chapman & Jenny Chapman Chapter 3 This presentation © 2004, MacAvon Media Productions Introduction to Computer Graphics.
Chapter 2 File Format Objectives (1 of 2) Identify the difference between vector based graphics and bitmap-based graphics Clarify bitmap and vector graphic.
Chapter 3 Image Files © 2013 Cengage Learning. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website,
Adobe photoshop digital image making. the basics Adobe PhotoShop is an image-editing program that lets you create and edit digital images. ◦PhotoShop.
Raster Graphics 2.01 Investigate graphic image design.
Ggplot2 A cool way for creating plots in R Maria Novosolov.
Image File Formats. What is an Image File Format? Image file formats are standard way of organizing and storing of image files. Image files are composed.
By: Catyana Brown Information Technology in a Global Society: Multimedia.
Introduction to Images & Graphics JMA260. Objectives Images introduction Photoshop.
Digital Graphics for Computer Games Pixels Types of Digital Graphics (Raster and Vector) Compression.
Digital Media Dr. Jim Rowan ITEC 2110 Chapter 3. Roll call.
Graphics and Image Data Representations 1. Q1 How images are represented in a computer system? 2.
HTML5 and CSS3 Illustrated Unit F: Inserting and Working with Images.
IS502:M ULTIMEDIA D ESIGN FOR I NFORMATION S YSTEM D IGITAL S TILL I MAGES Presenter Name: Mahmood A.Moneim Supervised By: Prof. Hesham A.Hefny Winter.
BITMAPPED IMAGES & VECTOR DRAWN GRAPHICS
Section 8.1 Section 8.2 Create a custom theme Design a color scheme
2.01 Understand Digital Raster Graphics
2.01 Understand Digital Raster Graphics
Introduction to Scanners
Exploring Computer Science - Lesson 3-4
Digital Illustration Chapter 6 File format.
Overview of R and ggplot2 for graphics
Chapter 3 Image Files © 2013 Cengage Learning. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website,
Exploring Computer Science - Lesson 3-4
Screen and Image Resolution
Inserting and Working with Images
2.01 Understand Digital Raster Graphics
RESEARCH AND APPLY GRAPHIC DESIGN TECHNIQUES #3
2.01 Investigate graphic image design.
Bitmap vs. Vector.
Chapter 3 Image Files © 2017 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
Exploring Computer Science - Lesson 3-4
Chapter III, Desktop Imaging Systems and Issues: Lesson IV Working With Images
A computer display is made up of small squares, called pixels.
CS Computer Graphics Valdosta State University, Spring 2018
Chapter 3:- Graphics Eyad Alshareef Eyad Alshareef.
Introduction to Computer Graphics
Screen and Image Resolution
2.01 Understand Digital Raster Graphics
Dr. Jim Rowan ITEC 2110 Chapter 3
2.01 Investigate graphic image design.
2.01 Understand Digital Raster Graphics
Lecture 2 Components of GIS
Web Programming– UFCFB Lecture 7
Dr. Jim Rowan ITEC 2110 Chapter 3
2.01 Investigate graphic image design.
2.01 Investigate graphic image design.
Lecture 4 - Introduction to Computer Graphics
Screen and Image Resolution
Comp 20 - Training & Instructional Design
Presentation transcript:

Overview of R and ggplot2 for graphics R Bootcamp 2018 Michael Hallquist

A layered grammar of graphics In many software packages, each graph type is treated separately (scatter plot, pie chart, bar chart). This leads to the burden of needing to learn the syntax or interface of each plot type. It also obscures the reality that data can typically be visualized in many different ways (and trying out a few is usually beneficial) A related challenge is implementing consistent decisions for colors, axis labeling, grid lines, etc. A good grammar will allow us to gain insight into the composition of complicated graphics, and reveal unexpected connections between seemingly different graphics (Cox, 1978)

A layered grammar of graphics Base dataset Layer: Data Aesthetic mappings Statistical transformation Geometric object Position adjustment Scale (one for each aesthetic mapping) Coordinate system Facet specification

5 components of graphical layers Mapping: A set of rules for translating a given variable into an attribute of the graph (e.g., age is mapped to the x axis) Data: A dataset to be used when drawing marks (using a geom_ or stat_ function). If none is specified, the base dataset is used. Geom: The graphical primitive to draw on the figure according to the mapping (e.g., point, text, or boxplot). Stat: The statistical transformation or computation to use to draw marks onto the figure. (Mutually exclusive with geom) Position: Method used to adjust overlapping data (e.g., stack, dodge)

Long/molten format for ggplot Many problems with visualization reflect that data are not sufficiently wrangled and/or tidy. Ggplot prefers data in a long format where each row is an observation and columns denote variables that can be mapped to the graph. Thus, a response variable, height, that will mapped to the y axis needs to be in one variable, even if another variable, sex, is included for faceting. This allows for a simple tabular key-value lookup. Remember the gather function from tidyr.

ggplot(dataset, aes(x=weight, y=height)) + geom_jitter() + facet_wrap(~SEX) + theme_bw(base_size=26)

Introduction to graphics devices in R Vector graphic: uses polygons based on control points that have positions in a Cartesian coordinate system. Simply put: Plotting information is with respect to the Cartesian plane, not the display device. Hence, vector graphics can be rescaled to any device without loss of fidelity. Bitmap (raster) graphic: image is a rectangular grid of pixels (irreducible units) where each pixel has specific graphical properties (hue, saturation, brightness [HSB]). The dimensions of the image can only be changed by resampling (and potentially interpolating) the original rectangular pixel grid.

Vector versus bitmap graphics When possible, prefer vector graphics: Typically smaller file size Can be easily edited after the fact (e.g., in Inkscape) Avoids concerns about resolution/dots per inch (DPI) At times bitmap will be better: Journal requires TIFF at 600 DPI (check your proofs!!) Graphic contains photographs or other visually graded media There are many points to display (50k+) Small file size is paramount (e.g., for email) Potential font embedding issues Microsoft Office files (they're getting better)

Bitmaps: lossy versus lossless Bitmap graphics can be compressed by not storing each pixel's unique HSB value on the file system (technically related to projection to a lower dimension subspace). Lossy compression: Original HSB values discarded in favor of size optimization. Most common: .jpg Lossless compression: Original HSB values preserved and reconstructed for display (less efficient, but no loss of information). Most common: .png, .gif

Recommendations for graphic output Vector graphics: .pdf (for publication) .svg (for edits in Illustrator or Inkscape) -> export to PDF? Get aspect ratio and relative font size right Bitmap graphics: .png (lossless compression) for charts and text .jpg (Quality 90+) for photos or complex illustrations with tonal gradients. Minimum DPI for printing of 240. 300-600 preferred. Minimum DPI of 150 for displaying on screen. Need to get width and height exactly right since resizing involves interpolation