Ask Your Question
0

Plot 3d data

asked 2022-05-09 23:58:10 +0200

BenBoggart gravatar image

updated 2022-05-13 10:12:32 +0200

I've been unable to find any viable solution although I'm quite sure there's an easy one.

I'd like to plot a surface from a matrix with some hundred rows that specify a point each, i.e. x y z. The point3d function does the ranges right but lacks the surface option; list_plot3d provides the surface, but does plot by the row/colum indeces instead of the x,y values.

Which function would do the trick?

Ben

(Edit) As there have been a few views, but no answer: I would appreciate a negative statement as "such a function is not implemented" as well. Thanks.

edit retag flag offensive close merge delete

Comments

give us a toy minimal example of the data you want to plot

FrédéricC gravatar imageFrédéricC ( 2022-05-13 15:48:16 +0200 )edit

2 Answers

Sort by » oldest newest most voted
0

answered 2022-05-13 22:51:09 +0200

Emmanuel Charpentier gravatar image

updated 2022-05-13 22:56:11 +0200

WorksForMe(TM) in Sagecell and in Sage 9.6.rc3. Let's assess the density of a bivariate standard normal by plotting 1000 random points (I use R's functions by pure laziness...) :

set_random_seed(0)
X=r.rnorm(1000,0,1)._sage_()
Y=r.rnorm(1000,0,1)._sage_()
Z=r.dnorm(list(map(lambda u,v:sqrt(u^2+v^2), X, Y)),0,1)._sage_()
P=list_plot3d(list(zip(X,Y,Z)))
show(P, aspect_ratio=[1,1,5])

See for yourself !

HTH,

edit flag offensive delete link more
0

answered 2022-05-13 18:12:04 +0200

FrédéricC gravatar image

Shooting in the dark, here is a tentative

def plot_cloud_matrix(M):
    m = len(M)
    n = len(M[0])
    P = point3d(M[0][0])
    for i in range(m-1):
        for j in range(n-1):
            pta = M[i][j]
            ptb = M[i+1][j]
            ptc = M[i+1][j+1]
            ptd = M[i][j+1]
            P += polygon3d([pta,ptb,ptc,ptd])
    return P

plot_cloud_matrix([[(0,1,2),(0,1,1.2)],[(0.5,1,2),(0.1,1,1.1)]])
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2022-05-09 23:58:10 +0200

Seen: 31 times

Last updated: May 13