Ggplot2

ggplot2: Themes

Introduction This is the last post in the series Elegant Data Visualization with ggplot2. In the previous post, we learnt to combine multiple plots. In this post, we will learn to modify the appearance of all non data components of the plot such as: axis legend panel plot area background margin facets Libraries, Code & Data We will use the following libraries in this post:

ggplot2: Faceting

Introduction This is the 19th post in the series Elegant Data Visualization with ggplot2. In the previous post, we learnt to modify the title, label and bar of a legend. In this post, we will learn about faceting i.e. combining plots. Libraries, Code & Data We will use the following libraries in this post: readr ggplot2 All the data sets used in this post can be found here and code can be downloaded from here.

ggplot2: Legend - Part 6

Introduction This is the 18th post in the series Elegant Data Visualization with ggplot2. In the previous post, we learnt how to modify the legend of plot when alpha is mapped to a categorical variable. In this post, we will learn to modify legend title label and bar So far, we have learnt to modify the components of a legend using scale_* family of functions. Now, we will use the guide argument and supply it values using the guide_legend() function.

ggplot2: Legend - Part 5

Introduction This is the 17th post in the series Elegant Data Visualization with ggplot2. In the previous post, we learnt how to modify the legend of plot when size is mapped to continuous variable. In this post, we will learn to modify the following using scale_alpha_continuous() when alpha or transparency is mapped to variables: title breaks limits range labels values Libraries, Code & Data We will use the following libraries in this post:

ggplot2: Legend - Part 4

Introduction This is the 16th post in the series Elegant Data Visualization with ggplot2. In the previous post, we learnt how to modify the legend of plot when shape is mapped to categorical variables. In this post, we will learn to modify the following using scale_size_continuous when size aesthetic is mapped to variables: title breaks limits range labels values Libraries, Code & Data We will use the following libraries in this post:

ggplot2: Legend - Part 3

Introduction This is the 15th post in the series Elegant Data Visualization with ggplot2. In the previous post, we learnt how to modify the legend of plots when aesthetics are mapped to variables..In this post, we will learn to modify the following using scale_shape_manual when shape is mapped to categorical variables: title breaks limits labels values Libraries, Code & Data We will use the following libraries in this post:

ggplot2: Legend - Part 2

Introduction This is the 14th post in the series Elegant Data Visualization with ggplot2. In the previous post, we learnt how to modify the legend of plots when aesthetics are mapped to variables. In this post, we will continue to explore different ways to modify/customize the legend of plots. Specifically, we will learn to modify the following using scale_fill_manual() when fill is mapped to categorical variables: title breaks limits labels values

ggplot2: Legend - Part 1

Introduction This is the 13th post in the series Elegant Data Visualization with ggplot2. In the previos post, we learnt how to modify the axis of plots. In this post, we will focus on modifying the appearance of legend of plots when the aesthetics are mapped to variables. Specifically, we will learn to modify the following when color is mapped to categorical variables: title breaks limits labels values

ggplot2: Guides - Axes

Introduction This is the twelfth post in the series Elegant Data Visualization with ggplot2. In the previous post, we learnt to build histograms. Now that we have learnt to build different plots, let us look at different ways to modify the axis. Along the way, we will also explore the scale_*() family of functions. Modify X and Y axis title labels limits breaks position In this module, we will learn how to modify the X and Y axis using the following functions:

ggplot2: Histogram

Introduction This is the eleventh post in the series Elegant Data Visualization with ggplot2. In the previous post, we learnt to build box plots. In this post, we will learn to build histogram specify bins modify color fill alpha bin width line type line size map aesthetics to variables A histogram is a plot that can be used to examine the shape and spread of continuous data.

ggplot2: Box Plots

Introduction This is the 9th post in the series Elegant Data Visualization with ggplot2. In the previous post, we learnt how to build bar charts. In this post, we will learn to: build box plots modify box color fill alpha line size line type modify outlier color shape size alpha The box plot is a standardized way of displaying the distribution of data. It is useful for detecting outliers and for comparing distributions and shows the shape, central tendancy and variability of the data.

ggplot2: Bar Plots

Introduction This is the ninth post in the series Elegant Data Visualization with ggplot2. In the previous post, we learnt to build line charts. In this post, we will learn to: build simple bar plot stacked bar plot grouped bar plot proportional bar plot map aesthetics to variables specify values for bar color bar line color bar line type bar line size Libraries, Code & Data We will use the following libraries in this post:

ggplot2: Line Graphs

Introduction This is the 8th post in the series Elegant Data Visualization with ggplot2. In the previous post, we learnt to build scatter plots. In this post, we will learn to: build simple line chart grouped line chart map aesthetics to variables modify line color type size Libraries, Code & Data We will use the following libraries in this post: readr ggplot2 All the data sets used in this post can be found here and code can be downloaded from here.

ggplot2: Scatter Plots

Introduction This is the fifth post in the series Elegant Data Visualization with ggplot2. In the previous post, we learnt about text annotations. In this post, we will: build scatter plots modify point color fill alpha shape size fit regression line Libraries, Code & Data We will use the following libraries in this post: readr ggplot2 All the data sets used in this post can be found here and code can be downloaded from here.

ggplot2: Text Annotations

Introduction This is the sixth post in the series Elegant Data Visualization with ggplot2. In the previous post, we learnt to modify the axis and plot labels. In this post, we will learn to add text to the plots. add custom text modify color modify size modify fontface modify angle Libraries, Code & Data We will use the following libraries in this post: readr ggplot2 All the data sets used in this post can be found here and code can be downloaded from here.

ggplot2 - Axis and Plot Labels

Introduction This is the fifth post in the series Elegant Data Visualization with ggplot2. In the previous post, we learnt about aesthetics. In this post, we will learn to: add title and subtitle to the plot modify axis labels modify axis range remove axis format axis Basic Plot Let us start with a simple scatter plot. We will continue to use the mtcars data set and examine the relationship between displacement and miles per gallon using geom_point().

ggplot2 - Introduction to Aesthetics

Introduction This is the fourth post in the series Elegant Data Visualization with ggplot2. In the previous post, we learnt about geoms and how we can use them to build different plots. In this post, we will focus on the aesthetics i.e. color, shape, size, alpha, line type, line width etc. We can map these to variables or specify values for them. If we want to map the above to variables, we have to specify them within the aes() function.

ggplot2 - Introduction to geoms

Introduction This is the third post in the series Elegant Data Visualization with ggplot2. In the previous post, we learnt how to create plots using the qplot() function. In this post, we will create some of the most routinely used plots to explore data using the geom_* functions. Libraries, Code & Data We will use the following libraries in this post: readr ggplot2 tibble dplyr All the data sets used in this post can be found here and code can be downloaded from here.

ggplot2: Quick Tour

Introduction This is the second post in the series Elegant Data Visualization with ggplot2. In the previous post, we understood the concept of grammar of graphics and even built a bar plot step by step while exploring the different components of a plot/chart. In this post, we will learn to quickly build a set of plots that are routinely used to explore data using qplot(). It can be used to quickly create plots but also has certain limitations.