How to Create a Non-Ugly Figure — A Recipe for Python Data Visualization

https://miro.medium.com/max/1200/0*J_iozUP32Z-NwQ_E

Original Source Here

Step 3. Set the overall theme

Even if you don’t do anything, seaborn applies some default settings to our figures, and certainly they don’t look bad. However, to customize the appearance of your figures, it’s a good idea to apply an overall theme, which allows you to create multiple figures in an aesthetically consistent way. Here’s how you can set the default theme.

Set Theme

As you can see, all the parameters have default values set in the set_theme method. To show you what each of the parameters means, let’s see how a figure looks like with the default theme:

Figure Using The Default Theme (Screenshot by Author)

Now, it’s time to explore these parameters individually. Please note that you can consider set_theme as a convenience method, and there are separate functions that are specifically used to set the parameters. I’ll mention these functions whenever applicable.

Set the Context
The context parameter has four pre-configured options: paper, notebook, talk, and poster. The following figure shows you each one’s appearance. The most significant differences that can catch your eyeballs easily are the title and the markers.
Alternative functions to look: plotting_context & set_context.

Set Context (Screenshot by Author)

Set the Style
The style applies to the axes of the figure by mainly controlling the grid. There are five possible pre-configured settings: whitegrid, white, ticks, darkgrid, and dark. Each of these settings is shown below for an example. Everything should be straightforward except that “ticks” enables tick marks on the axes, in comparison with “white”.
Alternative functions to look: axes_style & set_style.

Set Style (Screenshot by Author)

Set the Palette
Figures are boring if they don’t have colors. If you need to set separate colors for different components of your figure, it’s not the easiest job for most of us. Fortunately, you can pick a palette that automatically applies a variety of colors to your plot. There are tons of pre-configured palettes that you can choose. Here’s part of the list.

'Accent', 'Accent_r', 'Blues', 'Blues_r', 'BrBG', 'BrBG_r', 'BuGn', 'BuGn_r', 'BuPu', 'BuPu_r', 'CMRmap', 'CMRmap_r', 'Dark2', 'Dark2_r', 'GnBu', 'GnBu_r', 'Greens', 'Greens_r', 'Greys',
...
'turbo_r', 'twilight', 'twilight_r', 'twilight_shifted', 'twilight_shifted_r', 'viridis', 'viridis_r', 'vlag', 'vlag_r', 'winter', 'winter_r'

If you don’t know how to find the palette names, an easy way to locate this information is from the error message when you call sns.set_palette(“anything_you_want”).
Alternative functions to look: color_palette & set_palette.

Set Palette (Screenshot by Author)

There are some other parameters that you can configure. But as you may tell, these three have the most impact on the aesthetics of your figure. Please feel free to explore the remaining parameters.

AI/ML

Trending AI/ML Article Identified & Digested via Granola by Ramsey Elbasheer; a Machine-Driven RSS Bot

%d bloggers like this: