Join us and get access to hundreds of tutorials and a community of expert Pythonistas.

Unlock This Lesson

This lesson is for members only. Join us and get access to hundreds of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Hint: You can adjust the default video playback speed in your account settings.
Hint: You can set the default subtitles language in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please see our video player troubleshooting guide to resolve the issue.

Visual Style Using Themes

To see the xkcd webcomic and to explore further about concepts covered in this lesson, you can check out the following resources:

00:00 In this lesson, you’ll learn about how you can use themes to change the look and feel of the plots that you’re creating with plotnine. There’s a couple of themes built-in, and you’re going to see two of them in action right now.

00:12 If you head back over to your Jupyter Notebook, you can do these imports. I already wrote them out for you here. It’s going to be the mpg dataset again, and you’re just using ggplot(), aes() (aesthetics), and geom_bar() to create a plot.

00:24 So, you’re doing a bar plot on the class of the cars again. And just to show you, this is how the default theme looks like that plotnine uses. And now you can change these themes by just adding another layer in here.

00:38 So, similar to how you added the layers before, you can say from plotnine import theme_dark, for example. And then you can add the dark theme down here, theme_dark(), and it’ll change the look of your plot.

00:56 There’s a couple of themes that are available like this. You can choose the ones that fit for what you want to display. A fun one I wanted to show you here is theme_xkcd. If you know, xkcd is writing web comics and has a specific style of drawing graphs, and you can simulate that in here as well.

01:14 So if you apply the xkcd theme, then you get a plot that looks like this, which, if you compare it to some of the web comics, this is kind of like the style that this person uses to create graphs.

01:25 I’ll have a link to this website also in the description if you want to get some laughs out of reading over a couple of these pretty good web comics.

01:33 And this is how you can use themes to change the look and feel of your plots. In the next lesson, you’re going to learn how you can export some of these plots that you generated and save them as files.

Become a Member to join the conversation.