# Example of making a 2D histograms, extracting its content and making some modifications
from jhplot import HPlotter,H2D
from java.util import Random
from java.awt import Font;
h1 = H2D("My 2D Test",15,-3.0, 3.0, 15, -3.0, 3.0)
rand = Random()
for i in range(100):
h1.fill(0.5*rand.nextGaussian(),rand.nextGaussian())
harray=h1.binHeights()
herror=h1.binErrors()
print len(harray)
print type(harray)
# print array with binHeights
n1=0
n2=0
newvalues = []
newerrors= []
from array import *
for row in harray:
new = []
err = []
for val in row:
print '{:4}'.format(val),
# if value is 0, set it to -1
if (val==0): val=-1
new.append(val)
err.append(0)
n2=n2+1
n1=n1+1
newvalues.append(new)
newerrors.append(err)
print
# reset histogram with new values
h1.setContents(newvalues, herror)
c1 = HPlotter("Canvas",600,600)
c1.setNameX("c τ [cm]",Font("Arial", Font.PLAIN, 26))
c1.setNameY("β",Font("Arial", Font.PLAIN, 26))
c1.setTicFont(Font("Arial", Font.PLAIN, 18))
c1.visible()
c1.setStatBox(0)
c1.draw(h1,"ColorMap")
Ads help maintain this website.