0% found this document useful (0 votes)
61 views4 pages

A Simple Trick That Significantly Improves The Quality of Matplotlib Plots

Matplotlib plots are often blurry when scaled or zoomed due to being rendered as images by default. Rendering plots as scalable vector graphics (SVG) instead significantly improves their quality, as SVGs can be scaled without loss of quality. The newsletter provides a simple one-liner code to configure Matplotlib to render plots as SVG for sharper output.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
61 views4 pages

A Simple Trick That Significantly Improves The Quality of Matplotlib Plots

Matplotlib plots are often blurry when scaled or zoomed due to being rendered as images by default. Rendering plots as scalable vector graphics (SVG) instead significantly improves their quality, as SVGs can be scaled without loss of quality. The newsletter provides a simple one-liner code to configure Matplotlib to render plots as SVG for sharper output.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

5/25/23, 10:05 AM Yahoo Mail - A Simple Trick That Significantly Improves The Quality of Matplotlib Plots

A Simple Trick That Significantly Improves The Quality of Matplotlib Plots

From: Daily Dose of Data Science ([email protected])

To: [email protected]

Date: Wednesday, April 12, 2023 at 03:35 AM CDT

Open in app or online

A Simple Trick That Significantly


Improves The Quality of Matplotlib
Plots
A simple one-liner to go from dull to sharp plots.
AVI CHAWLA
APR 12

SHARE

about:blank 1/4
5/25/23, 10:05 AM Yahoo Mail - A Simple Trick That Significantly Improves The Quality of Matplotlib Plots

Matplotlib plots often appear dull and blurry, especially when scaled or
zoomed. Yet, here's a simple trick to significantly improve their quality.

Matplotlib plots are rendered as an image by default. Thus, any


scaling/zooming drastically distorts their quality.

Instead, always render your plot as a scalable vector graphic (SVG). As the
name suggests, they can be scaled without compromising the plot's quality.

As demonstrated in the image above, the plot rendered as SVG clearly


outshines and is noticeably sharper than the default plot.

The following code lets you change the render format to SVG. If the
difference is not apparent in the image above, I would recommend trying it

about:blank 2/4
5/25/23, 10:05 AM Yahoo Mail - A Simple Trick That Significantly Improves The Quality of Matplotlib Plots

yourself and noticing the difference.

from matplotlib_inline.backend_inline import


set_matplotlib_formats
set_matplotlib_formats('svg')

Alternatively, you can also use the following code:

%config InlineBackend.figure_format = 'svg'

P.S. If there’s a chance that you don’t know what is being depicted in the bar
plot above, check out this YouTube video by Numberphile.

👉 Read what others are saying about this post on LinkedIn.

👉 Tell me you liked this post by leaving a heart react ❤️.

👉 If you love reading this newsletter, feel free to share it with friends!

Share Daily Dose of Data Science

Find the code for my tips here: GitHub.

I like to explore, experiment and write about data science concepts and tools.
You can read my articles on Medium. Also, you can connect with me on
LinkedIn and Twitter.

LIKE COMMENT RESTACK

Read Daily Dose of Data Science in the app


Listen to posts, join subscriber chats, and never miss an update from Avi Chawla.

about:blank 3/4
5/25/23, 10:05 AM Yahoo Mail - A Simple Trick That Significantly Improves The Quality of Matplotlib Plots

© 2023 Avi Chawla


India
Unsubscribe

about:blank 4/4

You might also like