Get startedGet started for free

Tweaking your plots

1. Tweaking your plots

Throughout the previous chapters, you've have learned how to take your visualizations from good to great by thinking deeply about the data they are representing and how the presentation affects the viewer. In this lesson, we will be talking about the last stage of a visualization project. Putting the final aesthetic tweaks on your plot.

2. Looking at the small things

Throughout this course and your previous DataCamp visualization courses, you've learned how to make large-scale changes to your visualization. For instance, choosing the right color palette. These types of changes help at every level of your visualization process. However, now that you're preparing your visualization for its final form stop and investigate your visualization as a viewer, not a creator. This means going back and looking at the small details of your visualization.

3. Is the aesthetic appropriate?

Consider things like whether the plot's background and style fit that of the visualization's final destination, such as a scientific paper or blog post. For instance, some journals may not allow the default background grid Seaborn applies to plots.

4. Font-sizes

Another, easy to forget adjustment is the font-size. Is it legible? Will a viewer without perfect vision be able to read the axes and title of your plot in its final destination? Background styles and font-sizes are just a couple of the innumerable small tweaks you can make to a plot, but they are invaluable. Let's take a look at how to do them with Seaborn.

5. Adjusting background grids (a)

Tweaking the general aesthetic of your plot is very valuable. It can take a plot from looking like every other plot to come out of Python, to one that shows effort has been put into it. Seaborn makes changing the overall theme of your plots very easy with the function set_style(). There are five built-in styles: 'darkgrid',

6. Adjusting background grids (b)

'whitegrid',

7. Adjusting background grids (c)

'dark',

8. Adjusting background grids (d)

'white',

9. Adjusting background grids (e)

and 'ticks'. Choosing the right one for your plot depends, as always, on the context. Are grid lines needed to help the viewer orient with the axes? Try 'whitegrid' or 'darkgrid'. Does the publication require a plain white background? Use 'white' or 'ticks'.

10. Removing spines from plots

Another quick way of cleaning up your plot is by removing the border lines from around the edges. Just like setting the style, all you need to do is call a simple Seaborn function, despine(), to do it. By default despine() removes the top and right borders, but by setting the arguments bottom and left to true you can remove the remaining bottom and left borders.

11. Removing spines from plots

While often these spines are valuable for orienting the viewer on the axes, sometimes they can be removed to give the plot a less constrained aesthetic.

12. Setting font size

One of the most commonly neglected but massively important tasks in polishing a visualization is making sure the font size is right. Luckily, Seaborn makes it easy to modify the sizes of all the fonts in your plot. Using Seaborn's set() function, you can scale up the size of your plot's text. Simply set the argument font_scale to some scalar value. For instance, a value of 1 will result in no change from default, whereas 2 will be double the size of the default, and 0.5 will be half.

13. Let's tweak some plots

Now that you're familiar with how to make these subtle but very important tweaks to your plots let's put them to work on some visualizations of our farmers market data.