from jhplot import HChart,P1D c1 = HChart("Canvas",600,500, 2, 1) c1.setGTitle("Polar coordinates") c1.visible() c1.cd(1,1) c1.setName("Polar coordinates-I") c1.setChartPolar() p1= P1D("test 1") p2= P1D("test 2") # fill rand = Random() for i in range(20): x=4.0*i # x-value p1.add(i*4, 10.0*rand.nextGaussian()); p2.add(i*2, 5.0*rand.nextGaussian()); c1.add(p1) c1.add(p2) c1.update() c1.cd(2,1) p3= P1D("Example") for i in range(0,3*360,5): p3.add( 90-i,i) c1.setChartPolar() c1.setName("Polar coordinates-II") c1.add(p3) c1.update() # export to some image (png,eps,pdf,jpeg...)
# NeuralNetwork. Build a bayesian Self-Organizing Map. Example II from jhplot import * from java.awt import Color from java.util import Random c1 = HPlot("Canvas") c1.setGTitle("Bayesian Self-Organizing Map") c1.visible() c1.setAutoRange() h1 = H1D("Data",20, -100.0, 300.0) r = Random() for i in range(2000): h1.fill(100+r.nextGaussian()*100) p1d=P1D(h1,0,0) p1d.setErrToZero(1) bs=HBsom() bs.setNPoints(30) bs.setData(p1d) bs.run() result=bs.getResult() result.setStyle("pl") result.setColor(Color.blue) c1.draw(p1d) c1.draw(result)
#@OUTPUT Integer series1_strokeWidth series1_strokeColor = "rgb(" + str(r.nextInt(255)) + "," + str( r.nextInt(255)) + "," + str(r.nextInt(255)) + ")" series1_fillColor = series1_strokeColor series1_strokeWidth = 1 series1_xvalues = [] series1_yvalues = [] series1_error = [] currentY = 0 for i in range(29): series1_xvalues.append(i) series1_yvalues.append(currentY) currentY += r.nextGaussian() series1_error.append(abs(r.nextGaussian())) r = Random() # Series 2 Outputs #@OUTPUT Double[] series2_xvalues #@OUTPUT Double[] series2_yvalues #@OUTPUT Double[] series2_error #@OUTPUT String series2_fillColor #@OUTPUT String series2_strokeColor #@OUTPUT Integer series2_strokeWidth series2_strokeColor = "rgb(" + str(r.nextInt(255)) + "," + str( r.nextInt(255)) + "," + str(r.nextInt(255)) + ")" series2_fillColor = series1_strokeColor
from java.awt import Color c1 = HPlot3D("Canvas", 500, 500) c1.setGTitle("Interactive 3D galaxy") c1.setRange(-10, 10, -10, 10, -10, 10) c1.setNameX("X") c1.setNameY("Y") c1.visible(1) # create P2D objects in 3D p1 = P2D("Galaxy") p1.setSymbolSize(2) p1.setSymbolColor(Color.blue) rand = Random() for i in range(5000): x = 3 * rand.nextGaussian() y = 3 * rand.nextGaussian() z = 0.4 * rand.nextGaussian() p1.add(x, y, z) c1.draw(p1) h2 = P2D("Core") h2.setSymbolSize(2) h2.setSymbolColor(Color.yellow) for i in range(5000): x = 0.9 * rand.nextGaussian() y = 0.9 * rand.nextGaussian() z = 0.8 * rand.nextGaussian() h2.add(x, y, z) c1.draw(h2)
# Data clustering | C | 1.7 | S.Chekanov | Perform a cluster analysis using jMinHEP GUI from java.util import Random from jminhep.cluster import * from jhplot import * # create data for analysis data = DataHolder("Example") # fill 3D data with Gaussian random numbers rand = Random() for i in range(100): a =[] a.append( 10*rand.nextGaussian() ) a.append( 2*rand.nextGaussian()+1 ) a.append( 10*rand.nextGaussian()+3 ) data.add( DataPoint(a) ) # start jMinHEP GUI c1=HCluster(data)
c1 = HPlot3D("Canvas",500,500) c1.setGTitle("Interactive 3D galaxy") c1.setRange(-10,10,-10,10,-10,10) c1.setNameX("X") c1.setNameY("Y") c1.visible(1) # create P2D objects in 3D p1= P2D("Galaxy") p1.setSymbolSize(2); p1.setSymbolColor(Color.blue); rand = Random() for i in range(5000): x=3*rand.nextGaussian() y=3*rand.nextGaussian() z=0.4*rand.nextGaussian() p1.add(x,y,z) c1.draw(p1) h2=P2D("Core") h2.setSymbolSize(2) h2.setSymbolColor(Color.yellow) for i in range(5000): x=0.9*rand.nextGaussian() y=0.9*rand.nextGaussian() z=0.8*rand.nextGaussian() h2.add(x,y,z) c1.draw(h2)
c1.valueLine(8.0, "First", "category3"); c1.valueLine(3.0, "Second", "category1"); c1.valueLine(2.8, "Second", "category2"); c1.valueLine(4.0, "Second", "category3"); c1.valueLine(1.0, "Second", "category3"); c1.update() # new plot. Fill a histogram h1=H1D("histogram",20,-2,2) h1.setFillColor(Color.blue) rand = Random() for i in range(1000): h1.fill(rand.nextGaussian()) c1.cd(2,1) c1.setName("Histogram example") c1.setRange(0,-2,2) c1.setRange(1,0,100) c1.add(h1) c1.update() c1.export("a.pdf") # export to some image (png,eps,pdf,jpeg...) # c1.export(Editor.DocMasterName()+".png")
import math from java.util import Random from java.lang import Double r = Random() # Series 1 Outputs #@OUTPUT Double[] series1_xvalues #@OUTPUT Double[] series1_yvalues #@OUTPUT Double[] series1_size #@OUTPUT String[] series1_label #@OUTPUT String[] series1_color #@OUTPUT String series1_markerColor series1_markerColor = "lightgreen" series1_xvalues = [] series1_yvalues = [] series1_size = [] series1_color = [] series1_label = [] for i in range(99): series1_xvalues.append(Double.valueOf(r.nextGaussian())) series1_yvalues.append(Double.valueOf(r.nextGaussian())) series1_size.append( Double.valueOf(4 / math.sqrt(series1_xvalues[i] * series1_xvalues[i] + series1_yvalues[i] * series1_yvalues[i]))) series1_color.append("rgb(" + str(r.nextInt(255)) + "," + str(r.nextInt(255)) + "," + str(r.nextInt(255)) + ")") series1_label.append("point " + str(i))
# NeuralNetwork. Build a bayesian Self-Organizing Map. Example I from java.util import Random from jhplot import * h1 = H1D("Data",20, -100.0, 300.0) r = Random() for i in range(2000): h1.fill(100+r.nextGaussian()*100) h1.fill(100+r.nextDouble()*100) p1d=P1D(h1,0,0) # write to a file p1d.toFile("data.txt") bs=HBsom() bs.setNPoints(30) bs.setData(p1d) bs.visible()
r = Random() # Series 1 Outputs #@OUTPUT Double[] series1_values #@OUTPUT String series1_strokeColor #@OUTPUT Integer series1_strokeWidth series1_strokeColor = "rgb(" + str(r.nextInt(255)) + "," + str( r.nextInt(255)) + "," + str(r.nextInt(255)) + ")" series1_strokeWidth = 2 series1_values = [] for i in range(999): series1_values.append(Double.valueOf(r.nextGaussian())) # Series 2 Outputs #@OUTPUT Double[] series2_values #@OUTPUT String series2_strokeColor #@OUTPUT Integer series2_strokeWidth series2_strokeColor = "rgb(" + str(r.nextInt(255)) + "," + str( r.nextInt(255)) + "," + str(r.nextInt(255)) + ")" series2_strokeWidth = 2 series2_values = [] for i in range(999): series2_values.append(Double.valueOf(r.nextGaussian() - 5))
c1.cd(1, 1) c1.setChartPie() c1.setName("Pie example") c1.valuePie("Hamburg", 1.0) c1.valuePie("London", 2.0) c1.valuePie("Paris", 1.0) c1.valuePie("Bern", 1.0) c1.update() # new plot c1.cd(1, 2) c1.setName("XY example") c1.setNameX("weeks") c1.setNameY("density") p1 = P1D("test 1") p1.setColor(Color.red) p2 = P1D("test 2") # fill rand = Random() for i in range(1000): x = 4.0 * i # x-value p1.add(i * 4, 10.0 * rand.nextGaussian()) p2.add(i * 2, 5.0 * rand.nextGaussian()) c1.add(p1) c1.add(p2) c1.update() # export to some image (png,eps,pdf,jpeg...) # c1.export(Editor.DocMasterName()+".png")
# 3D Plots | C | 1.7 | S.Chekanov | 3D histogram (H2D) and a 3D (F2D) function overlyed on HPlot3D from jhplot import HPlot3D, H2D, F2D from java.util import Random c1 = HPlot3D("Canvas", 600, 400) c1.setGTitle("F2D and H2D objects") c1.setTextBottom("Global X") c1.setTextLeft("Global Y") c1.setNameX("X") c1.setNameY("Y") c1.setColorMode(4) c1.visible(1) h1 = H2D("My 2D Test 1", 30, -3.0, 3.0, 30, -3.0, 3.0) f1 = F2D("8*(x*x+y*y)", -3.0, 3.0, -3.0, 5.0) rand = Random() for i in range(1000): h1.fill(0.4 * rand.nextGaussian(), rand.nextGaussian()) c1.draw(h1, f1) # export to some image (png,eps,pdf,jpeg...) # c1.export(Editor.DocMasterName()+".svg") c1.export("image.pdf") c1.export("image.eps")