Skip to content

fix for 3d subplots #545

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/plot3d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ for f in mplot3d_funcs
fs = string(f)
@eval @doc LazyHelp(axes3D,"Axes3D", $fs) function $f(args...; kws...)
using3D() # make sure mplot3d is loaded
ax = PyPlot.version <= v"3.4" ? gca(projection="3d") : plt."subplot"(projection="3d")
if PyPlot.version <= v"3.4"
ax = gca(projection="3d")
else
ax = gca()._subplotspec.get_geometry() == (1,1,0,0) ? plt."subplot"(projection="3d") : gca()
Copy link
Member

@stevengj stevengj Apr 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ax = gca()._subplotspec.get_geometry() == (1,1,0,0) ? plt."subplot"(projection="3d") : gca()
ax = gca()."get_subplotspec"()."get_geometry"() == (1,1,0,0) ? plt."subplot"(projection="3d") : gca()

seems to be the documented way to get the current subplotspec. (Also I tend to use quotes to suppress the attempt at conversion (which fails, but takes up time).)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't we just do

plt."subplot"(gca()."get_subplotspec"(), projection="3d")

?

end
pycall(ax.$fs, PyAny, args...; kws...)
end
end
Expand All @@ -74,7 +78,11 @@ for f in zlabel_funcs
fs = string("set_", f)
@eval @doc LazyHelp(axes3D,"Axes3D", $fs) function $f(args...; kws...)
using3D() # make sure mplot3d is loaded
ax = PyPlot.version <= v"3.4" ? gca(projection="3d") : plt."subplot"(projection="3d")
if PyPlot.version <= v"3.4"
ax = gca(projection="3d")
else
ax = gca()._subplotspec.get_geometry() == (1,1,0,0) ? plt."subplot"(projection="3d") : gca()
end
pycall(ax.$fs, PyAny, args...; kws...)
end
end
Expand Down