Contents

# 1D arrays

1D arrays in DataMelt are designed for numerical calculations and are optimized for numbers. We first consider P0D arrays (to hold double values) and P0I (to hold integer values)

from jhplot import P0D
p0=P0D("test")
for i in range(10):
print p0.toString()

One can view the data containers using several methods. One is toString() which converts data into a string. One can write data into a file (including a compression) using the method toFile(file). One can also view data in a sortable table using the method toTable():

from jhplot  import P0D
p0=P0D("test")
for i in range(1,50,2):
p0.toTable()

As for any DataMelt data object, one can write and read arrays into files using the method "toFile" and read using the method "read()"

p0.toFile("data.txt")


p0.read("data.txt")


If a file was zipped use the method "readZip()".

One can access various statistical characteristics of the P0D arrays as:

from jhplot  import P0D
p0=P0D("test")
for i in range(1,50,2):
print p0.getStatString()

<fc #008000>Exercise: try to increase the number of iteration to 1000 and see the output. </jnote>

# 2D arrays

2D arrays are based on the Java class P1D. This class can be used to show data in X-Y plane As before, one can fill such arrays using the method "add(x,y)".

Here is a simple example how to show several data sets on on X-Y graph:

from jhplot  import  P1D, HPlot
from java.awt import Color

p1=P1D("1st data set")
c1.draw(p1); c1.draw(p2)