1
votes

I am looking for a way to guarantee that in matplotlib's imshow, all pixels are visible in the resulting figure.

I use imshow to depict recurrence plots, where I need to be able to see fine lines of 1px thickness, because they can indicate something interesting going on.

Within Jupyter notebook, imshow is printed in the given figsize, and if that figsize is too small, small lines in the plot can disappear. How can I ensure that matplotlib and jupyter notebook do not to resize the image, but show all pixels?

1
They should not disappear. I think on older versions of matplotlib interpolation is used if not specified otherwise. Try to set interpolation=None or interpolation='nearest' when calling imshow. Not sure if this is your problem though. Can you maybe please show an exemplary plot which makes the problem easier to understand? - Solvalou
You should look into setting both figsize and dpi on the figure. - busybear

1 Answers

0
votes

If the 1px lines are spotty and visible when zooming in, you can make them visible by enabling interpolation:

axes.imshow(edges, cmap=plt.cm.gray, interpolation="bilinear")

Before:

enter image description here

After:

enter image description here