Matplotlib tutorial

How to Visualize Hilbert Matrix in Python

In 2D and 3D using Matplotlib

Pawel Jastrzebski
Geek Culture
Published in
7 min readAug 18, 2023

--

The other day I came across an article explaining what Hilbert matrix is and showing how to visualize it.

I liked the article and since the original content produced visualization in MATLAB I’ve shamelessly decided to steal the idea and reproduce the results in Python using Matplotlib.

This article will briefly explain:

  • what Hilbert matrix

However, its main purpose is to practice creating:

  • 2D heat map style plots
  • 3D plots
  • plots with colour bars

I’ll also show you a few ways you can use to calculate Hilbert matrix:

  • using for loops
  • using vectorization
  • wrapping a solution in a function

Let’s get to it.

Hilbert matrix

--

--

Pawel Jastrzebski
Geek Culture

I use Python 🐍 and Inkscape 🗻 for data viz 🖼 • matplotlib fan • I share tips, tutorials & articles - let me teach you something • Don't be a stranger 👋