From the course: Data Science Reporting with Quarto for Python

Unlock this course with a free trial

Join today to access over 24,600 courses taught by industry experts.

Using Matplotlib and Plotnine in Quarto

Using Matplotlib and Plotnine in Quarto

- [Instructor] Matplotlib and plotnine are fantastic data visualization tools in Python that you'll want to be able to use in Quarto. So we're in a .qmd file, in the 04_01b folder, and we're going to preview this document with the keyboard shortcut Command + Shift + K. That takes a couple of seconds. We need to render the documents and preview it when it's finished. We'll see a preview on the right-hand side of the screen. Okay, so we're generating a matplotlib chart here. And notice, we've used set_figwidth and set_figheight. Do you know what unit those functions use? Those use inches. And in the HTML formats, and in web content in general, inches don't really mean very much. If we want to control exactly how big something looks in web content, we need to save our matplotlib object as an image, and then insert that image, which we've done in the code. So if we scroll down in our input document, we can see we're using savefig on line 34, and line 37, we're using markdown to insert the…

Contents