Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue plotting big endian images #6671

Closed
jenshnielsen opened this issue Jul 1, 2016 · 5 comments
Closed

Issue plotting big endian images #6671

jenshnielsen opened this issue Jul 1, 2016 · 5 comments
Assignees
Milestone

Comments

@jenshnielsen
Copy link
Member

jenshnielsen commented Jul 1, 2016

Originally reported by Anik Halder on the mailing list http://matplotlib.1069221.n5.nabble.com/IPython-FITS-file-plotting-problem-tp47271.html

Consider this simple example:

import matplotlib.pyplot as plt
import numpy as np

x = np.arange(10)
X, Y = np.meshgrid(x,x)
Z = ((X-5)**2 + (Y-5)**2)**0.5

plt.imshow(Z, origin = "lower")
plt.colorbar()
plt.show()

plt.figure()
plt.imshow(Z.astype('>f8'), origin = "lower")
plt.colorbar()
plt.show()

Which produces:
right
And:
wrong

This works correctly in 1.5.1 so it looks like it's a regression in 2.x

@jenshnielsen jenshnielsen added this to the 2.0 (style change major release) milestone Jul 1, 2016
@tacaswell
Copy link
Member

I think this is a duplicate of #6394 which was fixed in #6422

@jenshnielsen
Copy link
Member Author

It sounds like that should have fixed it however I can still reproduce it with 2.0.0b1+98.gc4fa469 which I just installed.

@QuLogic
Copy link
Member

QuLogic commented Jul 2, 2016

It works on v1.5.x, but not v2.x. Bisect points to commit 1302606

Author: Thomas A Caswell <tcaswell@gmail.com>
Date:   Fri Mar 4 00:17:47 2016 -0500

    Merge pull request #6099 from mdboom/masked-image

    Fix #6069.  Handle image masks correctly

:040000 040000 7daaffa94619d32e28aa44502209445b5670cc8b c5e94ccc04761d2b02be7a55bd07598dc4830236 M  lib
:040000 040000 98a3d3dc7f7a61d7029d97f9f5e657f77cb582ec 6b646c30374dc76196d8b2b0a406d06e7f2159e2 M  src

@QuLogic
Copy link
Member

QuLogic commented Jul 2, 2016

More specifically:

eda09124a3d262bb47405924f44cdf11853f2b1e is the first bad commit
commit eda09124a3d262bb47405924f44cdf11853f2b1e
Author: Michael Droettboom <mdboom@gmail.com>
Date:   Wed Mar 2 10:46:46 2016 -0500

    Fix #6069.  Handle image masks correctly

    Alternative to #6070

    This works by converting the greyscale image to an RGBA image (with the
    alpha channel created correctly) prior to resizing in Agg.  This also
    removes the hack (that caused problems with over/under) where we were
    using negative values to indicate transparency.

:040000 040000 7daaffa94619d32e28aa44502209445b5670cc8b ff69631973998fa2efe6a5f932b9a79f02fdd088 M  lib

Also, edited top post to include creation of Z from the notebook.

@tacaswell
Copy link
Member

Ok, this behavior makes sense.

In [13]: matplotlib.cbook.safe_masked_invalid(Z.astype('>f8'), copy=True).data.dtype
Out[13]: dtype('>f8')

numpy is happily copy, but not forcing the data to be native. I have a PR on the way.

tacaswell added a commit to tacaswell/matplotlib that referenced this issue Jul 2, 2016
In cbook.safe_mask_invalid also ensure that the data is in
native byte order.

close matplotlib#6671 closes matplotlib#6394
tacaswell added a commit to tacaswell/matplotlib that referenced this issue Jul 2, 2016
In cbook.safe_mask_invalid also ensure that the data is in
native byte order.

close matplotlib#6671 closes matplotlib#6394
@tacaswell tacaswell self-assigned this Jul 2, 2016
tacaswell added a commit to tacaswell/matplotlib that referenced this issue Jul 2, 2016
In cbook.safe_mask_invalid also ensure that the data is in
native byte order.

close matplotlib#6671 closes matplotlib#6394
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants