[SciPy-User] Problem of 'rotated' data from mat-file when plotted

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[SciPy-User] Problem of 'rotated' data from mat-file when plotted

O.Zolotov
Dear All,

I try to ‘plot’ data from mat-file. The matlab file’s URL is
https://agupubs.onlinelibrary.wiley.com/action/downloadSupplement?doi=10.1002%2F2016JA023579&attachmentId=2190682395

(~80Mb!)

When I plot the figure, it looks rotated over the original one. Is
there a way to fix this? I tested it using SciLab also, and it
produced the figure as expected, so the problem is unlikely in the
file itself.  I use the following commands to plot the figure

import scipy.io as s
import numpy as np

ds2 = s.loadmat(r"jgra53413-sup-0003-DataSetS2.mat")
jx2, jy2, jz2 = ds2['jx'], ds2['jy'], ds2['jz']
x2, y2, z2 = ds2['x'][0], ds2['y'][0], ds2['z'][0]
X2, Y2 = np.meshgrid(x2,y2)

import matplotlib.pyplot as plt
plt.subplot(2,2,1)
plt.pcolor(X2, Y2, jz2[:,:,0])
plt.colorbar()
plt.show()

The original and plotted images are attached.

Regards,
Oleg

_______________________________________________
SciPy-User mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/scipy-user

original.png (44K) Download Attachment
rotated(unexpectedly).png (6K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Problem of 'rotated' data from mat-file when plotted

Juan Nunez-Iglesias
Hi Oleg,

I haven’t gone carefully over your code but I suspect it has to do with mixing row/column coordinates with x/y (cartesian) coordinates. See this document for a brief explanation in the context of images:


So you probably have to mess with x2 and y2 somewhere to transpose them. Probably in the call to meshgrid, where NumPy would expect row/column and you are providing x/y.

Juan.

On 23 Mar 2018, 12:26 PM -0400, O.Zolotov <[hidden email]>, wrote:
Dear All,

I try to ‘plot’ data from mat-file. The matlab file’s URL is
https://agupubs.onlinelibrary.wiley.com/action/downloadSupplement?doi=10.1002%2F2016JA023579&attachmentId=2190682395

(~80Mb!)

When I plot the figure, it looks rotated over the original one. Is
there a way to fix this? I tested it using SciLab also, and it
produced the figure as expected, so the problem is unlikely in the
file itself. I use the following commands to plot the figure

import scipy.io as s
import numpy as np

ds2 = s.loadmat(r"jgra53413-sup-0003-DataSetS2.mat")
jx2, jy2, jz2 = ds2['jx'], ds2['jy'], ds2['jz']
x2, y2, z2 = ds2['x'][0], ds2['y'][0], ds2['z'][0]
X2, Y2 = np.meshgrid(x2,y2)

import matplotlib.pyplot as plt
plt.subplot(2,2,1)
plt.pcolor(X2, Y2, jz2[:,:,0])
plt.colorbar()
plt.show()

The original and plotted images are attached.

Regards,
Oleg

_______________________________________________
SciPy-User mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/scipy-user

_______________________________________________
SciPy-User mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/scipy-user