[Matplotlib-users] axes properties
ben.v.root at gmail.com
Wed Mar 22 15:15:51 EDT 2017
fig.gca(projection='3d') is perfectly valid, but you need to realize what
it does. It will only work if it is a single plot in the figure, and that
that is the *first* reference to the plot. If some other plotting action
has already happened, then it wouldn't work, because fig.gca() means "get
the current axes in the figure, if it exists; if it doesn't exist yet,
create one with these parameters". So, if an axes already exists, then
it'll fetch that one, and it may not be a 3d axes. Also, if you plan to do
subplots, then `gca()` may be limiting since it is not explicit about which
subplot in a figure it is referring to.
On Wed, Mar 22, 2017 at 1:57 PM, Jean-Philippe Grivet <
jean-philippe.grivet at wanadoo.fr> wrote:
> Thanks a lot Benjamin and Vincent for your most kind and detailed answers.
> In reply to Vincent, I regret that the authors of Matplotkib did not pursue
> the wrapper idea and propose a function plot3d(x,y,z); it would make life
> I copied from the net (I can't remember where) the following code fragment:
> from mpl_toolkits.mplot3d import Axes3D
> import numpy as np
> import matplotlib.pyplot as pt
> fig = pt.figure()
> ax = fig.gca(projection='3d')
> surf = ax.plot_wireframe(X, Y, Z, rstride = 10,cstride = 10)
> which looks rather similar to Matlab syntax and works well for me.
> Is that considered to be obsolete or in bad style ?
> Thanks again,
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Matplotlib-users