O'Reilly logo

R Data Analysis Cookbook - Second Edition by Kuntal Ganguly

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How it works...

First, we create a box plot and then add the title and x axis and y axis labels respectively.

Then we add legends, by specifying an extra attribute filled within the aesthetic, and use the labs method to define the legend title. We also modify the position of the legend in the plot.

Finally, we show how to remove the legend (if it is not required) using guides() and specifying the scale variable (in this example, it is fill).

Note: Appearance of labels and title can also be modified through the theme() function, which we will discuss in the next recipe.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required