 |
Using JavaView to make a graph
Source code name: "javaview_graph.py"
Programming language: Python
Topic: Graphics/3D
DMelt Version 1.4. Last modified: 06/22/1974. License: Pro
https://datamelt.org/code/cache/javaview_graph_7948.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.
# shows own data as a graph over the x-y plane.
# Own data is given as an array of z-values which determine
# the height of each vertex.
# @author Konrad Polthier, Sergei Chekanov
from jv.geom import PgElementSet
from jhplot import HJavaView
from java.lang import Math
geom = PgElementSet(3)
geom.setName("Sin-Cos Graph")
# Compute coordinates a graph over the x-y plane.
# Set number of lines in x and y directions.
numXLines = 8
numYLines = 5
# Allocate space for vertices.
geom.setNumVertices(numXLines*numYLines)
#Compute the vertices.
ind = 0
for i in range(numXLines):
x = Math.PI*i/(numXLines-1)
for j in range(numYLines):
y = Math.PI*j/(numYLines-1)
z = Math.sin(x)*Math.cos(y)
geom.setVertex(ind, x, y, z)
ind=ind+1
# Compute connectivity of a rectangular mesh.
geom.makeQuadrConn(numXLines, numYLines)
# just assign some colors.
geom.makeElementColorsFromXYZ()
geom.showElementColors(True)
c1= HJavaView()
c1.draw(geom)
c1.visible()
You see the box below because you did not login.