Show 2 sets of X-Y-Z points in 3D
Code: "p2d_points1.py". Programming language: Python DMelt Version 1. Last modified: 12/08/2015. License: Pro
https://datamelt.org/code/cache/p2d_points1_6278.py
To run this script using the DMelt IDE, copy the above URL link to the menu [File]→[Read script from URL] of the DMelt IDE.


 
from java.util import Random
from java.awt import Color
from jhplot  import HPlot3D, P2D

c1 = HPlot3D("Canvas",600,400)
c1.setGTitle("Interactive 3D plot with 2 sets of points") 
# define range in Xmin, Xmax, Ymin, Ymax,  Zmin, Zmax 
# if this range is not set, it will be set automatically
c1.setRange(-5,10,-5,5,-10,30)
c1.setNameX("X")
c1.setNameY("Y")
c1.visible(1)


# create random generator
rand = Random();

# create P2D objects in 3D 
h1= P2D("3D Gaussian 1")
h1.setSymbolSize(2);
h1.setSymbolColor(Color.blue);

for i in range(500):
               x=1+rand.nextGaussian()
               y=1+0.5*rand.nextGaussian()
               z=10+4.5*rand.nextGaussian()
               h1.add(x,y,z)


# create P2D objects in 3D
h2= P2D("3D Gaussian 2")
h2.setSymbolSize(4);
h2.setSymbolColor(Color.red);

for i in range(100):
               x=2+2*rand.nextGaussian()
               y=4+0.5*rand.nextGaussian()
               z=6+1.5*rand.nextGaussian()
               h2.add(x,y,z)


# draw them 
c1.draw(h1)
c1.draw(h2)


# export to some image (png,eps,pdf,jpeg...)
# c1.export(Editor.DocMasterName()+".png")

You see the box below because you did not login.