Adjusting scales

Besides setting aesthetic mapping for each plot or geometric object, one can use scale to control how variables are mapped to the visual property. In this recipe, we introduce how to adjust the scale of aesthetics in ggplot2.

Getting ready

Ensure you have completed the previous steps by storing sample_mean in your R environment.

How to do it…

Perform the following steps to adjust the scale of aesthetic magnitude in ggplot2:

  1. First, make a scatterplot by setting size=Total_Sales, colour=Province, y=Province, and conditional on Year_Month. Resize the point with the scale_size_continuous function:
    > g <- ggplot(data=sample_sum, mapping=aes(x=Year_Month, y=Province, size=Total_Sales, colour = Province ))
    > g + geom_point(aes(size=Total_Sales)) ...

Get R for Data Science Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.