Hi,
i want to draw a line segment in a 3d plot of the function x^2 + y^2.I have 
already plotted the function but i want to connect two points in the plot.
this is what I've done until now:


using PyPlot
using Distributions

function f(x)
    return (x[1]^2 + x[2]^2)
    return sin(x[1]) + cos(x[2])
end

n = 100
x = linspace(-1, 1, n)
y = linspace(-1,1,n)

xgrid = repmat(x',n,1)
ygrid = repmat(y,1,n)

z = zeros(n,n)

for i in 1:n
    for j in 1:n
        z[i:i,j:j] = f([x[i],y[j]])
    end
end

############
##  Plot  ##
############
fig = figure("pyplot_surfaceplot",figsize=(10,10))
ax = fig[:add_subplot](3,2,1, projection = "3d") 
ax[:plot_surface](xgrid, ygrid, z, rstride=1,edgecolors="k", cstride=1, 
cmap=ColorMap("gray"), alpha=0.8, linewidth=0.25) 
xlabel("X") 
ylabel("Y")
title("Surface Plot")



plot_wireframe(xgrid,ygrid,z)


scatter([1, 0],[0,3],z,c="Black")





Reply via email to