Skip to content

Commit 69a320e

Browse files
authored
Merge pull request #5 from stevengj/fix3d
fix 3d axis overwriting
2 parents 20f27ef + 5d87710 commit 69a320e

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/plot3d.jl

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,15 @@ const mplot3d_funcs = (:bar3d, :contour3D, :contourf3D, :plot3D, :plot_surface,
4242
:plot_trisurf, :plot_wireframe, :scatter3D,
4343
:text2D, :text3D, :view_init, :voxels)
4444

45+
function gca3d()
46+
using3D() # make sure mplot3d is loaded
47+
return version <= v"3.4" ? gca(projection="3d") : pyplot.subplot(gca().get_subplotspec(), projection="3d")
48+
end
49+
4550
for f in mplot3d_funcs
4651
fs = string(f)
4752
@eval @doc LazyHelp(axes3D,"Axes3D", $fs) function $f(args...; kws...)
48-
using3D() # make sure mplot3d is loaded
49-
ax = version <= v"3.4" ? gca(projection="3d") : pyplot.subplot(projection="3d")
50-
pycall(ax.$fs, args...; kws...)
53+
pycall(gca3d().$fs, args...; kws...)
5154
end
5255
end
5356

@@ -61,9 +64,7 @@ const zlabel_funcs = (:zlabel, :zlim, :zscale, :zticks)
6164
for f in zlabel_funcs
6265
fs = string("set_", f)
6366
@eval @doc LazyHelp(axes3D,"Axes3D", $fs) function $f(args...; kws...)
64-
using3D() # make sure mplot3d is loaded
65-
ax = version <= v"3.4" ? gca(projection="3d") : pyplot.subplot(projection="3d")
66-
pycall(ax.$fs, args...; kws...)
67+
pycall(gca3d().$fs, args...; kws...)
6768
end
6869
end
6970

0 commit comments

Comments
 (0)