@@ -22,10 +22,21 @@ keys(m::LazyPyModule) = keys(PyObject(m))
2222const axes3D = LazyPyModule (" mpl_toolkits.mplot3d.axes3d" )
2323const art3D = LazyPyModule (" mpl_toolkits.mplot3d.art3d" )
2424
25+ """
26+ using3D()
27+
28+ This function ensures that the `mplot3d` module is loaded for 3d
29+ plotting. This occurs automatically if you call any of the
30+ 3d plotting functions like `plot3D` or `surf`, but it may be
31+ necessary to call this function manually if you are passing
32+ `projection="3d"` explicitly to axes or subplot objects.
33+ """
34+ using3D () = (PyObject (axes3D); nothing )
35+
2536# ##########################################################################
2637# 3d plotting functions from mplot3d
2738
28- export art3D, Axes3D, surf, mesh, bar3D, contour3D, contourf3D, plot3D, plot_surface, plot_trisurf, plot_wireframe, scatter3D, text2D, text3D, zlabel, zlim, zscale, zticks
39+ export art3D, Axes3D, using3D, surf, mesh, bar3D, contour3D, contourf3D, plot3D, plot_surface, plot_trisurf, plot_wireframe, scatter3D, text2D, text3D, zlabel, zlim, zscale, zticks
2940
3041const mplot3d_funcs = (:bar3d , :contour3D , :contourf3D , :plot3D , :plot_surface ,
3142 :plot_trisurf , :plot_wireframe , :scatter3D ,
@@ -34,7 +45,7 @@ const mplot3d_funcs = (:bar3d, :contour3D, :contourf3D, :plot3D, :plot_surface,
3445for f in mplot3d_funcs
3546 fs = string (f)
3647 @eval @doc LazyHelp (axes3D," Axes3D" , $ fs) function $f (args... ; kws... )
37- PyObject (axes3D ) # make sure mplot3d is loaded
48+ using3D ( ) # make sure mplot3d is loaded
3849 ax = gca (projection= " 3d" )
3950 pycall (ax[$ fs], PyAny, args... ; kws... )
4051 end
@@ -50,7 +61,7 @@ const zlabel_funcs = (:zlabel, :zlim, :zscale, :zticks)
5061for f in zlabel_funcs
5162 fs = string (" set_" , f)
5263 @eval @doc LazyHelp (axes3D," Axes3D" , $ fs) function $f (args... ; kws... )
53- PyObject (axes3D ) # make sure mplot3d is loaded
64+ using3D ( ) # make sure mplot3d is loaded
5465 ax = gca (projection= " 3d" )
5566 pycall (ax[$ fs], PyAny, args... ; kws... )
5667 end
0 commit comments