Hi,

this is my best result... figure is acceptable when I use a lot of points...


#!/usr/bin/env python
# -*- coding: utf-8 -*-

import matplotlib
import matplotlib.art3d
import matplotlib.axes3d
import pylab


if __name__ == "__main__":

    data_filename = ...


    # We load data
    # 
    # x1 y1 v1
    # x2 y2 v2
    # x3 y3 v3
    # ...
    #
    data_file = pylab.load(data_filename)

    # We get x coordinate
    lstX = data_file[:, 0]
    # We get y coordinate
    lstY = data_file[:, 1]
    # We get data values
    lstV = data_file[:, 2]


    # We create list of lines from (x, y, 0) to (x, y, value)
    lstLines = [[(x, y, 0), (x, y, v)] for (x, y, v) in zip(lstX, lstY,
lstV)]


    # We create the figure
    fig = pylab.figure(1)
    # We get the axe reference
    ax  = matplotlib.axes3d.Axes3D(fig)
    # We create a matplotlib line collection
    lines = matplotlib.art3d.Line3DCollection(lstLines, linewidths=5)
    # We add the collection to the axes
    ax.add_3DCollection(lines)
    # Auto scale
    ax.auto_scale_xyz(lstX, lstY, lstV, ax.has_data())

    # Draw
    pylab.show()


    # Bye
    exit(0)



Example of data file :

0 0 -4.49132
0 1 0.676531
0 2 -1.60375
0 3 -0.184649
0 4 0.958887
0 5 -0.165971
1 0 -0.0216472
1 1 0.157346
1 2 -0.372853
1 3 0.2576
1 4 0.654506
2 0 0.139453
2 1 -0.204437
2 2 0.151606
2 3 0.271027
3 0 0.222327
3 1 0.921501
3 2 0.500956
4 0 0.104108
4 1 0.415777
5 0 0.244248
-- 
View this message in context: 
http://www.nabble.com/3D-histogram-tp16986530p20268667.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to