HerClau
HerClau

Reputation: 171

How to plot a 3-D function using Julia's Plots package?

Is it possible to reproduce this graph using the Julia Plots Package? Plotting using gnuplot

x = y = -15:0.4:15
f1 = (x,y) -> @. sin(sqrt(x*x+y*y))/sqrt(x*x+y*y)
surf(x, y, f1, w = :p, marker = "dot", Axes(hidden3d = :on))

enter image description here

Upvotes: 0

Views: 942

Answers (1)

Benoit Pasquier
Benoit Pasquier

Reputation: 3015

Not exactly the same, but you can plot a surface with surface:

using Plots
x = y = -15:0.4:15
f(x,y) = sin(sqrt(x^2+y^2))/sqrt(x^2+y^2)
surface(x, y, f)

which will give

surface plot

or a wireframe

wireframe(x, y, f)

will give

wireframe plot

But if you really want a 3D scatter, then you need to create the mesh by hand and rearrange the data into vectors I think, like

X = [x for x in x for y in y]
Y = [y for x in x for y in y]
scatter3d(X, Y, f.(X,Y))

scatter3d plot

Upvotes: 5

Related Questions