3D data with Z in color in 3D display using VisAd methods
Source code name: "hvisadd_list_dots.py"
Programming language: Python
Topic: Plots/3D
DMelt Version 1.9. Last modified: 07/09/1971. License: Pro
https://datamelt.org/code/cache/hvisadd_list_dots_5005.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.awt import *
from visad import Display,RealTupleType,ScalarMap,RealType
from visad import Irregular3DSet,DataReferenceImpl
from jhplot import *
from java.util import Random

c1=HVisAd()
display=c1.getDisplay()

XX = RealType("X", None, None)
YY = RealType("Y", None, None)
ZZ = RealType("Z", None, None)
domain_tuple = RealTupleType(XX,YY,ZZ)

# fill random numbers
r=Random()
X,Y,Z=[],[],[]
for j in range(10000):
     X.append(r.nextGaussian())
     Y.append(r.nextGaussian())
     Z.append(r.nextGaussian())
ntuple=[X,Y,Z] 
domain_set = Irregular3DSet(domain_tuple, ntuple)
print domain_set

dR=display.getDisplayRenderer()
dR.setForegroundColor(Color.gray)
dR.setBackgroundColor(Color.blue)
dR.setCursorColor(Color.red)

# X, Y are the usual axes
mX=ScalarMap( XX, Display.XAxis )
mY=ScalarMap( YY, Display.YAxis )
mX.setScalarName("X")
mY.setScalarName("Y")
display.addMap( mX )
display.addMap( mY )
mX.setScaleColor( [0,0,0] )
mY.setScaleColor( [0,0,0]  )

# show Z component in color
mZ=ScalarMap( ZZ, Display.RGBA )
mZ.setScalarName("Z")
display.addMap( mZ )

# Create a data reference and set the FlatField as our data
data_ref = DataReferenceImpl("data_ref")
data_ref.setData( domain_set )
display.addReference( data_ref )

c1.visible() 


You see the box below because you did not login.