FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Added broadcasting support in some mplot3d methods by WeatherGod · Pull Request #1074 · matplotlib/matplotlib · GitHub

Repository navigation

Added broadcasting support in some mplot3d methods - #1074

Merged
WeatherGod merged 1 commit into
matplotlib:masterfrom
WeatherGod:mplot3d/input_broadcast2
Aug 17, 2012
Merged

WeatherGod merged 1 commit into
matplotlib:masterfrom
WeatherGod:mplot3d/input_broadcast2

Conversation

Copy link
Copy Markdown
Member

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

pelson commented Aug 12, 2012

Copy link
Copy Markdown
Member

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)

Copy link
Copy Markdown
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 merged commit 2798e47 into matplotlib:master Aug 17, 2012
WeatherGod deleted the mplot3d/input_broadcast2 branch July 23, 2014 12:57
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

2 participants


Back | FazBrowse Home | New Git URL