JuliaPy / PyPlot.jl

Plotting for Julia based on matplotlib.pyplot
https://github.com/JuliaPy/PyPlot.jl
MIT License
469 stars 85 forks source link

fix for 3d subplots #545

Closed PaulSoderlind closed 2 years ago

PaulSoderlind commented 2 years ago

The current implementation has the problem that it overwrites subplots (see https://github.com/JuliaPy/PyPlot.jl/issues/532).

One of the problems with finding a good solution is (I believe) that the projection of an existing subplot cannot be easily changed. With this PR, the following works well

x = collect(-10:10)
y = collect(-11:11)
z = x.^2 .+ y'.^2

using PyPlot

figure()
subplot(221,projection="3d")
  surf(x, y, z')
  zlim(0,250)
  title("A")
subplot(222,projection="3d")
  surf(x, y, -z')
  zlim(-250,0)
  title("B")

figure()
  #ax = PyPlot.axes(projection="3d")     #works w/wo this
  surf(x, y, z')
  zlim(0,250)
  title("A")