Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Know your problem
Know your data
Visualise your data
Work with your chart
15. Tip: get rid of the clutter
Check yourself

Instruction

Here's another way to make your chart more professional.

Don't use grid lines unless you need them. These lines are useful when we are reading category heights, but when they are presented with the category (i.e. the x axis) variables, they are redundant.

You remove x-axis lines by using the theme function:

theme(panel.grid.major.x = element_blank())

The theme() function can change the appearance of all non-data components in a plot. In this case, we want the main grid for the x axis removed. So we set the display element to element_blank(). This will do the trick.

Exercise

Remove vertical grid lines from the plot by adding the theme() command to the barplot variable. Complete the template.

When you're done, press the Run and Check Code button to check your code.

Note that in template we left the + operator at the end of a line. R is smart - it understands that this way you tell it that the statement is not over and it has to read the next line. As you can see it helps in formatting the code and make things much more readable!

Stuck? Here's a hint!

You should write:

theme(panel.grid.major.x = element_blank())