Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 10

Visualizations in R

Visualizations with
ggplot2 package

In ggplot2 a plot
is made up of
layers
Different elements in the layers of the
graph
• Geoms: known as ‘geometric objects’
• Bar, line, dot or scatter, etc.
• Also has aesthetic properties (how do they look, eg.: Triangle or square)
• aes(): known as aesthetics
• variables that we want to plot (Xand Y)
• control the appearance of graph elements, for example, their colour, size, style
and location
• Aesthetics can be defined in general for the whole plot, or individually for a
specific layer
Different elements in the layers of the
graph
• The finished plot is made up of layers
• Each layer contains some geometric
• Element (such as bars, points, lines, text) known as a geom
• The appearance and location of these geoms (e.g., size, colour, shape
used) is controlled by the aesthetic properties (aes()).
The anatomy of a graph
Geometric objects
Facets to avoid over plotting
• useful tool for avoiding overplotting
• Splitting a plot into subgroups.
• Done in two ways:
• Facet Grid: facet_grid()
• Facet Wrap: facet_wrap()
Why Scatterplot…???
• To look at the relationships between variables
• A scatterplot is a graph that plots each person’s score on one variable
against their score on another
• To detect the outliers

You might also like