Does anyone know how to plot a 3D surface with Julia's Pyplot with e.g the norm of the surface-gradient as the face color?
Similar to this topic for Python: Color matplotlib plot_surface command with surface gradient
We could plot 3D surfaces in Python too, the function to plot the 3D surfaces is plot_surface(X,Y,Z), where X and Y are the output arrays from meshgrid, and Z=f(X,Y) or Z(i,j)=f(X(i,j),Y(i,j)). The most common surface plotting functions are surf and contour. TRY IT!
The axes3d present in Matplotlib's mpl_toolkits. mplot3d toolkit provides the necessary functions used to create 3D surface plots. Surface plots are created by using ax. plot_surface() function.
A 3D surface plot is a three-dimensional graph that is useful for investigating desirable response values and operating conditions. A surface plot contains the following elements: Predictors on the x- and y-axes. A continuous surface that represents the response values on the z-axis.
I saw this and I just HAD to make it work. It was almost supported out of the box with Plots.jl, using the PyPlot backend. I just had to swap out for a custom matplotlib shader to apply a different z-matrix.
You'll notice that I'm accessing numpy's gradient function (imported through PyCall
), and I'm wrapping the gradient matrix G
so that it doesn't get sliced into columns. All in all... much simpler than the python example!
using Plots; pyplot();
x = y = LinRange(-5.0, 5.0, 30)
z = sin(sqrt(Float64[xi^2+yi^2 for xi = x, yi = y]))
surface(x, y, z, alpha = 0.7)
using PyCall
Gx, Gy = Plots.pynb.pymember(:gradient)(z)
surface(x, y, z, alpha = 0.8, zcolor = wrap(G))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With