3d surface plotting using the X Y Z coordinated points accessing from excelsheet (xlsx)

977 views
Skip to first unread message

Vint19

unread,
Dec 30, 2013, 6:30:15 AM12/30/13
to wncc...@googlegroups.com
Hi Guys,

Can anyone help on How to plot the 3d surface using the X Y Z points in the form of Excelsheet (xlsx) accessing it using pandas and plotting using the matplotlib.

I was able to access the data using Pandas as follows,

import pandas as pd

import numpy

data = pd.ExcelFile('datafile.xlsx')

ws = data.parse('Node_Displacements')

X   = ws['X'].base

Y  = ws['Z'].base

Z  = ws['Y'].base


Now, how to plot the 3D surface (formed by these points) and get direction cosines of the surface normal.

                                                                   Excel file datafile.xlsx is attached.


Note: I am using python(x,y) (version 2.7.3.1) and matplotlib (version 1.3.1)


Thank you!


Regards

Vinayak

datafile.xlsx

Dilawar Singh

unread,
Dec 31, 2013, 7:02:38 PM12/31/13
to wncc_iitb
If you can export this to a csv file, life will be easier. You can either use csv module of python to parse it and use matplotlib to plot; or use gnuplot splot function to plot the surface plot.

--
Dilawar


--
--
The website for the club is http://stab-iitb.org/wncc
To post to this group, send email to wncc...@googlegroups.com
 
---
You received this message because you are subscribed to the Google Groups "Web and Coding Club IIT Bombay" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wncc_iitb+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
Dilawar
NCBS Bangalore

Saket Choudhary

unread,
Jan 1, 2014, 12:00:10 AM1/1/14
to wncc...@googlegroups.com
There are multiple ways to triangulate these points in space. Surface plots generally don't take inputs as vanila (X,Y,Z) as in case of scatter plots, you need a function of the sort z=f(x,y) that will define your grid. 


Axes3D_surfaceplot takes 2D arrays as input. You might need to input numpy's meshgrid as in the example. 

I also see that you have posted the same question to multiple mailing lists. A better idea is to post it to stackoverflow.com and just share the link with the mailing-list(s).


P.S. Your sheet is 'Node' and not 'Node_Displacements'. Y, Z are jumbled up as well. 



--

Vint19

unread,
Jan 5, 2014, 2:20:52 PM1/5/14
to wncc...@googlegroups.com
Thanx Dilawar!

Vint19

unread,
Jan 5, 2014, 2:37:02 PM1/5/14
to wncc...@googlegroups.com
Thanx Saket nice solution... I had used the plot_trisurf(x, y, z) ..... Axes3D module as you said.

In last code the Y Z shuffling was intentional.

Now, I stuck at how to get the list of keys of the surfaces and corresponding direction cosines of triangle surface normal, so that for second data set having same number of points I could triangulate with same connections.

I want to use above mentioned list of surface keys or say number, and associated nodes with them to triangulate the second data set.

Please help if you find something useful.

Thank you!
Reply all
Reply to author
Forward
0 new messages