Book Image

ggplot2 Essentials

By : Donato Teutonico
Book Image

ggplot2 Essentials

By: Donato Teutonico

Overview of this book

Table of Contents (14 chapters)
ggplot2 Essentials
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Bubble charts and dot plots


In the scatterplot section, we have seen how bivariate data can be represented in a typical x-y plot. In some cases, you may need to represent an additional variable in your plot, and we have already seen how different colors can be used to represent different types of data. One other option is to use the size of the symbols; if you are representing the data in points, you can, for instance, change the point size to represent an additional property of your data (an additional variable). This type of plot is usually called a bubble chart.

We can see a very easy example using the movie dataset we created in the Bar charts example. Please refer to that section for how to create this dataset.

We can create a plot of the different types of movies versus time by adding the size attribute of the symbol (in this case, they are points) to represent the budget of the movie. This is an example of the code to generate such a plot:

qplot(Year, Type, data=myMovieData, size=Budget...