Matplotlib

Photo by Gensa Hub on Unsplash

Matplotlib Animation – A Helpful Illustrated Guide

Creating animations in matplotlib is reasonably straightforward. However, it can be tricky when starting, and there is no consensus for the best way to create them. In this article, I show you a few methods you can use to make amazing animations in matplotlib. Matplotlib Animation Example The hardest thing about creating animations in matplotlib …

Matplotlib Animation – A Helpful Illustrated Guide Read More »

Python Lists filter() vs List Comprehension – Which is Faster?

[Spoiler] Which function filters a list faster: filter() vs list comprehension? For large lists with one million elements, filtering lists with list comprehension is 40% faster than the built-in filter() method. To answer this question, I’ve written a short script that tests the runtime performance of filtering large lists of increasing sizes using the filter() …

Python Lists filter() vs List Comprehension – Which is Faster? Read More »

Legends add clarity to complex plots

Matplotlib Legend – A Helpful Illustrated Guide

You’ve plotted some data in Matplotlib but you don’t know which data shows what? It’s time for a legend! How to add a legend in Python’s Matplotlib library? Label it with the label keyword argument in your plot method. Before plt.show(), call plt.legend() your plot will be displayed with a legend. Here’s the minimal example: …

Matplotlib Legend – A Helpful Illustrated Guide Read More »