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

plot_surface and transposed arrays #1838

Closed
micfe03 opened this issue Mar 20, 2013 · 15 comments
Closed

plot_surface and transposed arrays #1838

micfe03 opened this issue Mar 20, 2013 · 15 comments

Comments

@micfe03
Copy link

micfe03 commented Mar 20, 2013

plot_surface(X, Y, Z, ..)
if you have non-square matrices and Z is transposed (Z.T), you
would expect an error message. However, X and Y become reshaped, such that

  1. the plot is messed up
  2. as a side effect X and Y are scrambled after the call
@WeatherGod
Copy link
Member

On Wed, Mar 20, 2013 at 7:19 AM, micfe03 notifications@github.com wrote:

plot_surface(X, Y, Z, ..)
if you have non-square matrices and Z is transposed (Z.T), you
would expect an error message. However, X and Y become reshaped, such that

  1. the plot is messed up
  2. as a side effect X and Y are scrambled after the call

Which version of matplotlib are you using? I believe I fixed this at some
point.

@micfe03
Copy link
Author

micfe03 commented Mar 20, 2013

I installed the version that was most recent in autumn 2012. It says:

In [149]: ? plt
Type: module
String Form:<module 'matplotlib.pyplot' from
'/Library/Python/2.7/site-packages/matplotlib-1.2.x-py2.7-macosx-10.7-intel
.egg/matplotlib/pyplot.pyc'>
File:
/Library/Python/2.7/site-packages/matplotlib-1.2.x-py2.7-macosx-10.7-intel.
egg/matplotlib/pyplot.py

I could not find any old issue on the problem, so I assumed that it was
still present.

On 3/20/13 2:52 PM, "Benjamin Root" notifications@github.com wrote:

On Wed, Mar 20, 2013 at 7:19 AM, micfe03 notifications@github.com wrote:

plot_surface(X, Y, Z, ..)
if you have non-square matrices and Z is transposed (Z.T), you
would expect an error message. However, X and Y become reshaped, such
that

  1. the plot is messed up
  2. as a side effect X and Y are scrambled after the call

Which version of matplotlib are you using? I believe I fixed this at some
point.

Reply to this email directly or
view it on GitHub
<#1838 (comment)
4>.

@WeatherGod
Copy link
Member

On Wed, Mar 20, 2013 at 9:56 AM, micfe03 notifications@github.com wrote:

I installed the version that was most recent in autumn 2012. It says:

In [149]: ? plt
Type: module
String Form:<module 'matplotlib.pyplot' from
'/Library/Python/2.7/site-packages/matplotlib-1.2.x-py2.7-macosx-10.7-intel

.egg/matplotlib/pyplot.pyc'>
File:
/Library/Python/2.7/site-packages/matplotlib-1.2.x-py2.7-macosx-10.7-intel.

egg/matplotlib/pyplot.py

I could not find any old issue on the problem, so I assumed that it was
still present.

/Michael

Oooh, just found the issue. It is an edge-case where one dimension is a
multiple of the other (e.g., 5x10). This, by itself, is bad enough. But
apparently, the underlying call to np.broadcast_arrays() appears to be
modifying the original object's strides, which I think is a numpy bug.

@WeatherGod
Copy link
Member

Actually, just realized I screwed up my own example... I can not reproduce your issue. Could you provide a short example to demonstrate it.

@micfe03
Copy link
Author

micfe03 commented Mar 20, 2013

Here you go.

If you want to see the scrambled plot, you have to replace Z with
something deterministic ;-)

On 3/20/13 4:44 PM, "Benjamin Root" notifications@github.com wrote:

Actually, just realized I screwed up my own example... I can not
reproduce your issue. Could you provide a short example to demonstrate it.

Reply to this email directly or
view it on GitHub
<#1838 (comment)
0>.

@WeatherGod
Copy link
Member

nothing attached. I think you need to paste the code in the text because github strips out attachments, I think.

@micfe03
Copy link
Author

micfe03 commented Mar 21, 2013

Hi,

I sent this yesterday from my mobile, but I think it could not handle the
reply address construction in your email:

Sorry, did not know that. Here is the code:

import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

if name == 'main':
Z = np.random.uniform(0,1,(6,7))
x = np.arange(Z.shape[0])
y = np.arange(Z.shape[1])
X, Y = np.meshgrid(x, y)
print X
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.plot_surface(X, Y, Z)
plt.show()
print X

On 3/20/13 5:13 PM, "Benjamin Root" notifications@github.com wrote:

nothing attached. I think you need to paste the code in the text because
github strips out attachments, I think.

Reply to this email directly or
view it on GitHub
<#1838 (comment)
8>.

@WeatherGod
Copy link
Member

I was only able to reproduce your problem with matplotlib v1.1.x. With v1.2.x and above, the patch that I mentioned earlier catches these sorts of issues and raises an exception saying that the arrays have incompatible dimensions.

Somehow, you are running a different version of matplotlib than you think. Try putting in a "import matplotlib; print matplotlib.version" line in your code to make certain.

@micfe03
Copy link
Author

micfe03 commented Mar 21, 2013

In [18]: import matplotlib; print matplotlib.version
1.2.x

But it is on Mac OS, maybe that makes a difference?

On 3/21/13 2:19 PM, "Benjamin Root" notifications@github.com wrote:

I was only able to reproduce your problem with matplotlib v1.1.x. With
v1.2.x and above, the patch that I mentioned earlier catches these sorts
of issues and raises an exception saying that the arrays have
incompatible dimensions.
Somehow, you are running a different version of matplotlib than you
think. Try putting in a "import matplotlib; print matplotlib.version"
line in your code to make certain.

Reply to this email directly or
view it on GitHub
<#1838 (comment)
5>.

@WeatherGod
Copy link
Member

On Thu, Mar 21, 2013 at 10:48 AM, micfe03 notifications@github.com wrote:

In [18]: import matplotlib; print matplotlib.version
1.2.x

But it is on Mac OS, maybe that makes a difference?

Where did you get your install binary? This isn't an official release
binary because an official release wouldn't have an 'x' in the version
string. I suspect that your binary was built from the development branch
prior to my patch, which is in the 1.2.0 release.

@micfe03
Copy link
Author

micfe03 commented Mar 22, 2013

I have installed via Scipy superpack for Mac os v 10.7.4:

https://github.com/fonnesbeck/ScipySuperpack/tags

On 3/21/13 3:54 PM, "Benjamin Root" notifications@github.com wrote:

On Thu, Mar 21, 2013 at 10:48 AM, micfe03 notifications@github.com
wrote:

In [18]: import matplotlib; print matplotlib.version
1.2.x

But it is on Mac OS, maybe that makes a difference?

Where did you get your install binary? This isn't an official release
binary because an official release wouldn't have an 'x' in the version
string. I suspect that your binary was built from the development branch
prior to my patch, which is in the 1.2.0 release.

Reply to this email directly or
view it on GitHub
<#1838 (comment)
3>.

@WeatherGod
Copy link
Member

From the Superpack README:

All builds are based on recent development code from each package, which means though some bugs may be
fixed and features added, they also may be more unstable than the official releases.

Now that we have that mystery solved, I will be closing this bug.

@Tillsten
Copy link
Contributor

Tillsten commented Jun 4, 2014

This issues is still somewhate there:
matplot is showing garbage instead a error msg if x, y, z are all 1-dim arrays with the same shape.

@WeatherGod
Copy link
Member

Gah! didn't think of that edge case... handling this is gonna get
complicated. Could you open up a new issue for this edge case? Complete
with a test-able example?

On Wed, Jun 4, 2014 at 4:36 PM, Till Stensitzki notifications@github.com
wrote:

This issues is still somewhate there:
matplot is showing garbage instead a error msg if x, y, z are all 1-dim
arrays with the same shape.


Reply to this email directly or view it on GitHub
#1838 (comment)
.

@Tillsten
Copy link
Contributor

Tillsten commented Jun 4, 2014

See #3116

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