Raul Guarini Riva
Raul Guarini Riva

Reputation: 795

Is the "retina" configuration of Matplotlib dependent on subplot arrangement?

I am getting what seems to be a very annoying bug on Matplotlib when working on Jupyter Notebook. First consider this simple code:

import numpy as np
import matplotlib.pyplot as plt
%config InlineBackend.figure_format='retina'
plt.style.use('ggplot')

x = np.linspace(0, 1, 100)
y = np.cos(x)
z = np.sin(x)

Let's say I want to plots: (X, Y) and (X, Z) in the same figure. Apparently, the resolution at which the plot is displayed on Jupyter Notebook depends on whether I use two columns or two rows.

enter image description here

This plot is not "retina" at all. Now, If I try another configuration, I have the following:

enter image description here

This latter image is displayed with much more resolution (not sure if one can see that here on the website but I can clearly see on the screen of my laptop).

When I try to save the figure, no wonder both have the same resolution. This makes me wonder if there is something fishy in the connection between Matplotlib and the Jupyter notebook. Am I missing something? Can someone reproduce the error?

I could reproduce the error on a Google Colab notebook by the way.

I am on matplotlib version 3.2.2, with Jupyter notebook on version 6.4.6.

Upvotes: 0

Views: 420

Answers (0)

Related Questions