# Graphic Systems in R

If you want to plot a graph in R for your own consumption, it is pretty easy and you can generally do it with a few lines of code. However, if you are creating the graph for others consumption and want full control over all aspects of the graph, it will require some effort. The standard R distribution comes prepackages with powerful graphing capabilities. There are three in-built graphic packages, namely, Base, Grid and Lattice graphic packages. Apart from these three, there is also ggplot2, another popular graphic package for R.

### Base Graphics

Base graphics is the oldest and original graphic system built for R. This is the core plotting system and contains functions including `plot()`

, `hist()`

, `boxplot()`

and many others. The code for base graphics is in the graphics package, which is loaded by default when you start R.

### Grid

Grid is an alternative graphic system which was added to R at a later stage. It implements a completely different graphic system independent of the core graphics package. It is more like a framework and doesn't produce complete graphics by itself. For this reason, we seldom call functions from the grid package directly.

### Lattice

Lattice is an add-on graphic package that contains code for producing Trellis graphics - graphs that display a variable or the relationship between variables, conditioned on one or more other variables. It includes functions like `xyplot()`

, `bwplot()`

, `levelplot()`

, `histogram()`

. Lattice graphics in R make use of grid graphics. This is incompatible with Base graphics package.

### ggplot2

ggplot2 is a system for 'declaratively' creating graphics, based on "The Grammar of Graphics". You provide the data, tell 'ggplot2' how to map variables to aesthetics, what graphical primitives to use, and it takes care of the details. Here is the statement of purpose for the ggplo2 package - *ggplot2 is a plotting system for R, based on the grammar of graphics, which tries to take the good parts of base and lattice graphics and none of the bad parts. It takes care of many of the fiddly details that make plotting a hassle (like drawing legends) as well as providing a powerful model of graphics that makes it easy to produce complex multi-layered graphics.*

Base graphics are used most commonly and are a very powerful system for creating 2-D graphics. In this course, we will focus on the Base graphics system and ggplot2.

#### Course Downloads

Get smart about tech at work.

As a non-technical professional, learn how software works with simple explanations of tech concepts. Learn more...

- Overview of Data Visualization
- When to Use Bar Chart, Column Chart, and Area Chart
- What is Line Chart and When to Use It
- What are Pie Chart and Donut Chart and When to Use Them
- How to Read Scatter Chart and Bubble Chart
- What is a Box Plot and How to Read It
- Understanding Japanese Candlestick Charts and OHLC Charts
- Understanding Treemap, Heatmap and Other Map Charts
- Visualization in Data Science
- Graphic Systems in R
- Accessing Built-in Datasets in R
- How to Create a Scatter Plot in R
- Create a Scatter Plot in R with Multiple Groups
- Creating a Bar Chart in R
- Creating a Line Chart in R
- Plotting Multiple Datasets on One Chart in R
- Adding Details and Features to R Plots
- Introduction to ggplot2
- Grammar of Graphics in ggplot
- Data Import and Basic Manipulation in R - German Credit Dataset
- Create ggplot Graph with German Credit Data in R
- Splitting Plots with Facets in ggplots
- ggplot2 - Chart Aesthetics and Position Adjustments in R
- Creating a Line Chart in ggplot 2 in R
- Add a Statistical Layer on Line Chart in ggplot2
- stat_summary for Statistical Summary in ggplot2 R
- Facets for ggplot2 Charts in R (Faceting Layer)
- Coordinates in ggplot2 in R
- Changing Themes (Look and Feel) in ggplot2 in R

# Data Science for Finance Bundle: 43% OFF

**Data Science for Finance Bundle**for just $29 $51.