``` 1 # Real-life example. Data Mining Tutorial. 2 # S.Chekanov. April 2011 3 4 from jhplot import * 5 from jhplot.stat import LinReg 6 from java.awt import Color 7 8 # read data from external file 9 pn=PND('data','http://jwork.org/jhepwork/examples/data/pnd.d') 10 print pn.toString() 11 12 p0=pn.getP0D(1) # extract 2nd column and put to a 1D array 13 print p0.getStat() # print statistics 14 print p0.variance() 15 h1=p0.getH1D(10) # make a histogram with 10 bins 16 17 18 p1=pn.getP1D(1,2) # extract column 2 and 3 19 c1=HPlot("Plot",600,400,2,1) 20 c1.visible() 21 c1.cd(1,1) # go to the first drawing region 22 c1.setAutoRange() 23 c1.draw(h1) 24 25 26 c1.cd(2,1) # go to second drawing region 27 c1.setAutoRange() 28 r = LinReg(p1) 29 print "Intercept=",r.getIntercept(), "+/-",r.getInterceptError() 30 print "Slope=",r.getSlope(),"+/-",r.getSlopeError() 31 32 # create a string with a*x+b function 33 func='%4.2f*x+%4.2f' % (r.getSlope(),r.getIntercept()) 34 f1=F1D( func, p1.getMin(0), p1.getMax(0)) # define a function in the range of the data 35 36 p=r.getPredictionBand(Color.green) # calculate the prediction band 37 p.setLegend(False) # do not show the legend 38 p.setErrColor(Color.green) # color for error bars 39 c1.draw(p) 40 c1.draw(p1) # redraw data and the function 41 c1.draw(f1) 42 c1.export("tutorial_dmin1.eps") # make image file (EPS) 43 44 45 p2=pn.getP2D(0,1,2) # extract 1,2,3 columns 46 p3=pn.getP2D(0,2,3) # extract 1,3,4 columns 47 c2=HPlot3D("Plot",600,400,2,1) 48 c2.visible() 49 c2.setAutoRange() 50 c2.cd(1,1) 51 c2.setBoxColor(Color.white) 52 c2.draw(p2) 53 54 c2.cd(2,1) 55 c2.setBoxColor(Color(200,210,210)) 56 c2.setAutoRange() 57 c2.draw(p3) 58 c2.export("tutorial_dmin2.eps") ### © jHepWork. S.Chekanov ### ```