Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Know your data
Visualize your data – categorical variables
Work with your chart 2
16. Change tick labels
Check yourself 2

Instruction

Create proper tick labels on each axis.

Tick labels on each axis tell us about the range of data. They also make it possible to read specific variable values. Therefore, always make sure that tick labels properly represent the values of the relevant variable.

In our example, the tick labels on the y-axis represent proportions from zero to one: 0, 0.25, 0.5, 0.75, and 1. This is correct, but it is not very intuitive. The y-axis deals with the percent of each level of alcohol consumption for a wealth group; it should easily equate to percentages. Let's use standard whole percentages: 0, 25, 75, and 100.

We'll add the following command to the plot:

+ scale_y_continuous(labels = your_label_vector)

This will change the labels on the numerical y-axis. The labels argument will define the vector we choose for each tick in the axis.

Exercise

Change the y-axis variables to percentage-friendly values: 0, 25, 20, 75, 100. Use vector c(0, 25, 50, 75, 100) as labels.

When you're done, press Run and Check Code button.

Stuck? Here's a hint!

You should write:

scale_y_continuous(labels = c(0, 25, 50, 75, 100))