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

Added broadcasting support in some mplot3d methods #1074

Merged
merged 1 commit into from Aug 17, 2012

Conversation

WeatherGod
Copy link
Member

plot_surface and plot_wireframe gain the ability to allow for broadcastable inputs for X, Y, and Z.

@pelson
Copy link
Member

pelson commented Aug 12, 2012

So the inputs x y and z must all be 3d right?

>>> x = np.arange(3)
>>> y = np.arange(4)
>>> z = np.arange(5)

>>> np.broadcast_arrays(x, y, z)
ValueError: shape mismatch: two or more arrays have incompatible dimensions on axis 0.

>>> x = np.arange(3)
>>> y = np.arange(4)
>>> z = np.arange(5)
>>> x.shape = (-1, 1, 1)
>>> y.shape = (1, -1, 1)
>>> z.shape = (1, 1, -1)

>>> X, Y, Z = np.broadcast_arrays(x, y, z)
>>> print Y.shape
(3, 4, 5)
>>> print y.shape
(1, 4, 1)

@WeatherGod
Copy link
Member Author

On Sunday, August 12, 2012, Phil Elson wrote:

So the inputs x y and z must all be 3d right?

x = np.arange(3)
y = np.arange(4)
z = np.arange(5)

np.broadcast_arrays(x, y, z)
ValueError: shape mismatch: two or more arrays have incompatible dimensions on axis 0.

x = np.arange(3)
y = np.arange(4)
z = np.arange(5)
x.shape = (-1, 1, 1)
y.shape = (1, -1, 1)
z.shape = (1, 1, -1)

X, Y, Z = np.broadcast_arrays(x, y, z)
print Y.shape
(3, 4, 5)
print y.shape
(1, 4, 1)

First, the broadcasted results have to be 2d, not 3d. Second, your first
example fails because that isn't how broadcasting works. You might want to
read up on the concept. Third, the example you provided makes no sense
because how should the z portion be interpreted?

WeatherGod added a commit that referenced this pull request Aug 17, 2012
Added broadcasting support in some mplot3d methods
@WeatherGod WeatherGod merged commit 2798e47 into matplotlib:master Aug 17, 2012
@WeatherGod WeatherGod deleted the mplot3d/input_broadcast2 branch July 23, 2014 12:57
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

Successfully merging this pull request may close these issues.

None yet

2 participants