For me, the most convenient way to instantiate a figure with a regular grid of subplots is matplotlib.pyplot.subplots
but I cannot specify which type of projection is desired for the subplots
In [45]: from matplotlib.pyplot import subplots
...: from mpl_toolkits.mplot3d import axes3d
...: fig, axes = subplots(2,2, projection='3d')
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-45-023ffffb6940> in <module>
1 from matplotlib.pyplot import subplots
2 from mpl_toolkits.mplot3d import axes3d
----> 3 fig, axes = subplots(2,2, projection='3d')
~/lib/miniconda3/lib/python3.7/site-packages/matplotlib/pyplot.py in subplots(nrows, ncols, sharex, sharey, squeeze, subplot_kw, gridspec_kw, **fig_kw)
1207
1208 """
-> 1209 fig = figure(**fig_kw)
1210 axs = fig.subplots(nrows=nrows, ncols=ncols, sharex=sharex, sharey=sharey,
1211 squeeze=squeeze, subplot_kw=subplot_kw,
~/lib/miniconda3/lib/python3.7/site-packages/matplotlib/pyplot.py in figure(num, figsize, dpi, facecolor, edgecolor, frameon, FigureClass, clear, **kwargs)
543 frameon=frameon,
544 FigureClass=FigureClass,
--> 545 **kwargs)
546
547 if figLabel:
~/lib/miniconda3/lib/python3.7/site-packages/matplotlib/backend_bases.py in new_figure_manager(cls, num, *args, **kwargs)
3258 from matplotlib.figure import Figure
3259 fig_cls = kwargs.pop('FigureClass', Figure)
-> 3260 fig = fig_cls(*args, **kwargs)
3261 return cls.new_figure_manager_given_figure(num, fig)
3262
TypeError: __init__() got an unexpected keyword argument 'projection'
and I don't know if it is possible to inform an Axes, as returned from subplots
, that I want to use it for a 3D plotting, e.g.,
In [46]: fig, ax = subplots()
In [47]: ax.set_p[TAB]
set_path_effects() set_position()
set_picker() set_prop_cycle()
How can I change the projection type for a pre-existing Axes object?