I have created a figure using the following method:
import matplotlib.pyplot as plt
%matplotlib inline
fig1 = plt.figure(figsize=(2, 2), dpi=100)
I want to increase the resolution of the figure, so I increased the dpi of fig1
from 100 to 200. However, this changed the pixel dimensions from (200, 200) to (400, 400), which is something I do not want. If I let dpi=200 and figsize=(1, 1), the pixel dimensions remains (200, 200), but the image looks funny. Please see the output from my Jupyter notebook here.
Is there a way in Matplotlib to increase fig1
's resolution without altering its pixel dimension when rendered in Jupyter?
(Note: the code I used for generating the figures linked to above came from this question.)
To improve matplotlib image quality we can use greater dot per inch i.e dpi value (greater than 600) and pdf or . eps format can be recommended.
If you've already got the figure created, say it's 'figure 1' (that's the default one when you're using pyplot), you can use figure(num=1, figsize=(8, 6), ...) to change it's size etc.
Matplotlib can be a powerful tool for Python-based plotting, but if you've ever generated your plots inline within a Jupyter notebook you probably noticed that the default resolution of the rendered plot images is pretty low, which can leave your plots looking blurry/grainy and hard to read.
Specifically in the case of 2x (e.g. for retina screens), yes, use
%config InlineBackend.figure_format = 'retina'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With