Graphics in R. There are three plotting systems in R. base Convenient, but hard to adjust after the plot is created

Similar documents
Getting started with ggplot2

Introduction to Graphics with ggplot2

Plotting with ggplot2: Part 2. Biostatistics

A set of rules describing how to compose a 'vocabulary' into permissible 'sentences'

You submitted this quiz on Sat 17 May :19 AM CEST. You got a score of out of

Data Visualization Using R & ggplot2. Karthik Ram October 6, 2013

Ggplot2 QMMA. Emanuele Taufer. 2/19/2018 Ggplot2 (1)

Creating elegant graphics in R with ggplot2

Introduction to ggvis. Aimee Gott R Consultant

An introduction to ggplot: An implementation of the grammar of graphics in R

The following presentation is based on the ggplot2 tutotial written by Prof. Jennifer Bryan.

Data Visualization in R

Plotting with Rcell (Version 1.2-5)

Facets and Continuous graphs

An Introduction to R Graphics

Graphical critique & theory. Hadley Wickham

Econ 2148, spring 2019 Data visualization

03 - Intro to graphics (with ggplot2)

Rstudio GGPLOT2. Preparations. The first plot: Hello world! W2018 RENR690 Zihaohan Sang

Table of Contents. Preface... ix

The diamonds dataset Visualizing data in R with ggplot2

Supplementary Materials of canvasdesigner

Package cowplot. March 6, 2016

Data Visualization in R

Making sense of census microdata

Introduction to Minitab 1

Data visualization with ggplot2

Visualizing Data: Customization with ggplot2

Package ggextra. April 4, 2018

R Workshop Guide. 1 Some Programming Basics. 1.1 Writing and executing code in R

Package ggseas. June 12, 2018

Data visualization in Python

Statistical transformations

LondonR: Introduction to ggplot2. Nick Howlett Data Scientist

Intro to R for Epidemiologists

Introduction to R and the tidyverse. Paolo Crosetto

Large data. Hadley Wickham. Assistant Professor / Dobelman Family Junior Chair Department of Statistics / Rice University.

Introduction to Data Visualization

An introduction to R Graphics 4. ggplot2

Visualizing the World

# Call plot plot(gg)

Package ggsubplot. February 15, 2013

Session 3 Nick Hathaway;

ggplot2 basics Hadley Wickham Assistant Professor / Dobelman Family Junior Chair Department of Statistics / Rice University September 2011

Data Handling: Import, Cleaning and Visualisation

Lecture 09. Graphics::ggplot I R Teaching Team. October 1, 2018

Importing and visualizing data in R. Day 3

Data Visualization. Andrew Jaffe Instructor

ggplot2: elegant graphics for data analysis

How to view details for your project and view the project map

Package ggspectra. May 7, 2018

Lecture 4: Data Visualization I

Stat405. Displaying distributions. Hadley Wickham. Thursday, August 23, 12

Stat 849: Plotting responses and covariates

Customizing Graphs Using R

Graphics in R Ira Sharenow January 2, 2019

Data Visualization. Module 7

Basics of Plotting Data

Install RStudio from - use the standard installation.

ggplot2 and maps Marcin Kierczak 11/10/2016

Gnuplot. in Action. Understanding Data with Graphs MANNING. (74 w. long.) PHILIPP K. JANERT. Greenwich

KANRI DISTANCE CALCULATOR. User Guide v2.4.9

1 The ggplot2 workflow

Module 10. Data Visualization. Andrew Jaffe Instructor

Learning Objectives for Data Concept and Visualization

DATA VISUALIZATION WITH GGPLOT2. Coordinates

Charts in Excel 2003

Transient Stability Analysis with PowerWorld Simulator

Making Maps: Salamander Species in US. Read in the Data

HPC Visualization with EnSight

OpenACC Based GPU Parallelization of Plane Sweep Algorithm for Geometric Intersection. Anmol Paudel Satish Puri Marquette University Milwaukee, WI

How to create a theograph. A step-by-step guide

Debugging Intel Xeon Phi KNC Tutorial

Contents. Basic Visualization Tools. Viewing Tools GNUPLOT 9/30/13. Viewing tools gnuplot Netpbm package ImageMagick Suite ezvizgeneric

Advanced Plotting with ggplot2. Algorithm Design & Software Engineering November 13, 2016 Stefan Feuerriegel

Memory Footprint of Locality Information On Many-Core Platforms Brice Goglin Inria Bordeaux Sud-Ouest France 2018/05/25

Scheduling Jobs onto Intel Xeon Phi using PBS Professional

Maps & layers. Hadley Wickham. Assistant Professor / Dobelman Family Junior Chair Department of Statistics / Rice University.

GRID Testing and Profiling. November 2017

social data science Data Visualization Sebastian Barfort August 08, 2016 University of Copenhagen Department of Economics 1/86

Package ggmosaic. February 9, 2017

Matthew Baker. Visualisation of Electrophoresis Gels using TEX

Stat 849: Plotting responses and covariates

EWMA / Time Series Plot Overlay

LAB 1 INSTRUCTIONS DESCRIBING AND DISPLAYING DATA

Package ggqc. R topics documented: January 30, Type Package Title Quality Control Charts for 'ggplot' Version Author Kenith Grey

Data Visualization Principles for Scientific Communication

Elixir Ad-hoc Report. Release Elixir Technology Pte Ltd

Parallel Programming Project Notes

Technology Assignment: Scatter Plots

Visualization of large multivariate datasets with the tabplot package

vdmr: Generating web-based visual data mining tools with R

Export any View of information

Simulation using MIC co-processor on Helios

Graph Set Up. Dave Lorenz. July 27, Abstract

Overview. Lecture 13: Graphics and Visualisation. Graphics & Visualisation 2D plotting. Graphics and visualisation of data in Matlab

PyPlot. The plotting library must be imported, and we will assume in these examples an import statement similar to those for numpy and math as

Introduction to R for Beginners, Level II. Jeon Lee Bio-Informatics Core Facility (BICF), UTSW

Outline day 4 May 30th

Quick. Efficient. Versatile. Graphing Software for Scientists and Engineers.

Transcription:

Graphics in R There are three plotting systems in R base Convenient, but hard to adjust after the plot is created lattice Good for creating conditioning plot ggplot2 Powerful and flexible, many tunable feature, may require some time to master We will focus on the ggplot2 package today 9/28/2016 HPC training series Fall 2016 0

Basic Concepts of ggplot2 An implementation of Grammar of Graphics by Leland Wilkinson, which represents abstraction of graphic objects and ideas Two ways of plotting The qplot function: similar to the base plotting system with more features The ggplot function: the engine of qplot powerful, flexible and full featured Make the plots in layers Plot the data Overlay a summary Metadata and annotation 9/28/2016 HPC training series Fall 2016 1

ggplot2 Components Data frame Aesthetic mappings: how data are mapped to color, size Geoms: geometric objects like points, lines, shapes. Facets: for conditional plots. Stats: statistical transformations like binning and smoothing. Scales: what scale an aesthetic map uses (example: male = red, female = blue). Coordinate system 9/28/2016 HPC training series Fall 2016 2

> head(smictiming,3) nmic tmic ncpu tcpu 1 1 1619.6359 1 113.28228 2 5 338.0819 2 61.05454 3 10 172.5692 3 43.35397 Example Data Frame Benchmark data on the SuperMIC cluster Four columns: nt ( number of threads), time, device ( mic or cpu ), node (number of nodes) > head(bmdata,3) nt time device node 1 1 33358.562 mic 1 2 5 6894.032 mic 1 3 10 3566.916 mic 1 > tail(bmdata,3) nt time device node 182 18 10.237771 cpu 16 183 19 9.936815 cpu 16 184 20 9.452416 cpu 16 9/28/2016 HPC training series Fall 2016 3

> head(smictiming,3) nmic tmic ncpu tcpu 1 1 1619.6359 1 113.28228 2 5 338.0819 2 61.05454 3 10 172.5692 3 43.35397 qplot Function > qplot(nt,bmdata[1,"time"]/time, data=subset(bmdata,node==1 & device=="mic")) 9/28/2016 HPC training series Fall 2016 4

Using ggplot2 > g <- ggplot(subset(bmdata,device=="mic"), aes(nt,speedup,color=factor(node))) > summary(g) data: nt, time, device, speedup, node [104x5] mapping: x = nt, y = speedup, colour = factor(node) faceting: facet_null() > g # No plot here yet Error: No layers in plot > g + geom_line() + geom_point() # Add geometric objects 9/28/2016 HPC training series Fall 2016 5

The same plot with decorations 9/28/2016 HPC training series Fall 2016 6

g <- ggplot(subset(bmdata,device=="mic"), aes(nt,speedup,color=factor(node))) # ggplot call g + geom_line(size=1) + # plot lines geom_point(size=5) + # plot points # Title and axis labels labs(x="number of OpenMP Threads", y="speedup", title="supermic Benchmark") + # Format the title, legends and axes theme(plot.title = element_text(colour="black", size=22, face="bold", vjust=2.5), legend.title = element_text(colour="black", size=16, face="bold"), legend.position=c(0.2,0.8), legend.text=element_text(face="italic", size=16), axis.title=element_text(size=16)) + scale_color_discrete(name="offload to Intel Xeon Phi", # Legend title and keys labels=c("1 node", "4 nodes", "9 nodes", "16 nodes")) + scale_x_continuous(limits=c(1, max(bmdata$nt)), # Limits and ticks of x axis breaks=c(1,seq(20,max(bmdata$nt),20))) + scale_y_continuous(limits=c(1, max(bmdata$speedup)), # Limits and ticks of y axis breaks=c(1,seq(20,max(bmdata$speedup),20))) + annotate("text", x=200, y=30, # Annotation text label="mic KMP AFFINITY=\n\"granularity=fine,balanced\"", size=8) Here s the code 9/28/2016 HPC training series Fall 2016 7

Plot with inset (The code can be found in the script) 9/28/2016 HPC training series Fall 2016 8

Plot with a 2x2 facet (The code can be found in the script) 9/28/2016 HPC training series Fall 2016 9

Plot Functions Plot a math function by using the stat_function() function p <- ggplot(data.frame(x=c(-3,3)), aes(x=x)) p + stat_function(fun = dnorm) 9/28/2016 HPC training series Fall 2016 10

Control The Output Format Graphic Devices File devices Bitmap: png, jpeg, etc. Vector: pdf, svg, etc. Screen devices (quartz, X11, etc.) Steps Launch a graphic device Functions: png(), pdf(), svg(), etc. Make the plot Close the device with dev.off() function 9/28/2016 HPC training series Fall 2016 11

R Scripts We can put all the commands in a script Run R scripts with the Rscript command [lyan1@qb4 Gnuplot-training]$ ls benchmark.r map3d.eps map3d.pdf multiplot.gpl time-01-node-smic.dat time-09-node-smic.dat input3d.dat map3d.gpl multiplot.eps multiplot.pdf time-04-node-smic.dat time-16-node-smic.dat [lyan1@qb4 Gnuplot-training]$ Rscript benchmark.r Warning messages: 1: Removed 22 rows containing missing values (geom_path). 2: Removed 22 rows containing missing values (geom_point). [lyan1@qb4 Gnuplot-training]$ ls -tr input3d.dat map3d.pdf time-04-node-smic.dat multiplot.eps smic_benchmark_1.pdf map3d.gpl multiplot.gpl time-09-node-smic.dat multiplot.pdf smic_benchmark_2.svg map3d.eps time-01-node-smic.dat time-16-node-smic.dat benchmark.r smic_benchmark_3.png 9/28/2016 HPC training series Fall 2016 12