# Intermediate Data Visualization With ggplot2

Dive deeper into ggplot2 and learn how to make a variety of different types of visualizations

Start## Key Concepts

Review core concepts you need to learn to master this subject

Histograms In R

Boxplots In R

The Fill Argument

The stat Parameter

The Position Argument

Error Bars In R

Customizing Discrete Axes In R

Customizing Continuous Axes In R

Histograms In R

Histograms In R

```
# Creates a histogram of the Ozone feature from the dataset airquality. In this case, each bin will have a width of 10.
airquality_histogram_binwidth <-
ggplot(airquality, aes(x = Ozone)) +
geom_histogram(binwidth = 10)
```

In R, the `geom_histogram()`

function from the `ggplot2`

library will create a histogram. The `binwidth`

argument sets the width of the bins in the histogram.

If the `binwidth`

argument is not used, the histogram will create 30 bins by default of equal size. It is recommended to use the `binwidth`

argument to make the histogram smoother.

Histograms are used to visualize the distribution of a continuous variable.

- 1In this lesson, we’ll explore a variety of different visualizations in R’s ggplot2 package. We’ll also go over different ways we can customize our plots to better …
- 2Histograms let us visualize the distribution of a continuous variable, in contrast to bar plots which show counts and other values for discrete and categorical variables. Histograms divide values o…
- 5Many times we are interested in seeing percentages within our data or how different values add up. We can do this using a stacked bar plot. Let’s turn to the msleep dataset included in ggplot2 de…
- 6Instead of stacking our fill variable in our bar graphs, we can also represent values of the variable side by side. This is known as a clustered bar plot. The plot below visualizes our msleep dat…
- 7By default, bar plots using geom_bar() show the count of observations for each value. We can also show other types of data, such as calculating and showing the mean instead. Let’s say we want to s…
- 8Often, we’ll want to show not only the mean of a value but also its standard error. This tells us how much variation there is around the mean – are most values close to the averages shown, or is t…
- 9Frequently, we’ll want to customize our axes to represent our data more clearly. For discrete variables, such as categories on the x axis of a bar plot, we may want to specify a particular order th…
- 10Similarly to discrete variables, we can add a scale_x_continuous() layer to customize continuous variables on our x axis, or a scale_y_continuous() layer to customize continuous variables on our y …

## What you'll create

Portfolio projects that showcase your new skills

## How you'll master it

Stress-test your knowledge with quizzes that help commit syntax to memory