Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

DPI-connected bug of imshow when using multiple masked arrays #3057

Copy link
Copy link
Closed
@Phlya

Description

@Phlya
Issue body actions

Initial discussion started here: http://stackoverflow.com/questions/23490289/matplotlib-shows-different-figure-than-saves-from-the-show-window

Essentially I need to combine a few arrays to make a whole image I want to produce using imshow. So that the arrays do not overlay each other I use masking (as in the example at StackOverflow) or I set some data to None, so that it is not plotted; I do this:

cmap = matplotlib.cm.get_cmap()
cmap.set_bad('w', 0.0)

See the whole working example:

import matplotlib
import matplotlib.pyplot as plt
import numpy as np

data = np.random.random((3000, 3000))
data[np.tril_indices_from(data, 1)] = None
data2 = np.random.random((3000, 3000))
data2[np.triu_indices_from(data2, -1)] = None

cmap = matplotlib.cm.get_cmap()
cmap.set_bad('w', 0.0)

plt.imshow(data, interpolation='none', cmap=cmap)
plt.imshow(data2, interpolation='none', cmap=cmap)
plt.locator_params(nbins=60)
plt.show()

So the thing is, if I look at such image in an interactive window everything looks perfect (e.g. I zoomed into top-left corner, so that the pixels are visible:
show_zoom_save

If I save the whole image to a file from the Save-dialog of the window, the image gets screwed, so that the pixels are much bigger, than they should (it is a printscreen of Inkscape with opened SVG-file, where I zoomed to approximately the same coordinates):
_046
Same goes to direct saving the image to disk (SVG):
_047
If I use only data, but not data2, the image looks good:
_048
If I save both of them, but change the dpi (e.g. to 900), the image changes and the so-to-say resolution gets better, but the image gets really messy:
_049
You can probably see, that some pixels are distorted. If not, here is a closer zoom into this image:
_050
At the same time you can see, that the white diagonal no more ends and starts in the very corner of the image.

As far as I understand, this is a bug, or at least undocumented behaviour, because I haven't found any mentioning of possibility of such weird effects anywhere. Using such plots (though not randomly generated) is crucial to my research, I would really like this fixed or being pointed out to a solution for this problem.

Please let me know, if you can reproduce such effects and if you need any further information from me.

I use matplotlib 1.3.1 on Ubuntu 14.04 with Python 2.7.6 and Spyder 2.2.5.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.