``` 1 # Canvas3D example. Using HPlot3D canvas for functions and histograms in 3D 2 3 from java.awt import Color,Font 4 from java.util import Random 5 from jhplot import F2D,H2D,HPlot3D 6 7 c1 = HPlot3D("Canvas",600,900, 2,3) 8 c1.visible(1) 9 c1.setGTitle("HPlot3D canvas tests") 10 rand =Random() 11 12 h1=H2D("My 2D Test1",30,-4.5, 4.5, 30, -4.0, 4.0) 13 h2=H2D("My 2D Test2",30,-4.5, 4.5, 30, -4.0, 4.0) 14 h3=H2D("My 2D Test3",10,-4.5, 4.5, 10, -4.0, 4.0) 15 f1=F2D("cos(x*y)*(x*x-y*y)", -2.0, 2.0, -2.0, 2.0) 16 f2=F2D("5*exp(-(x*x+y*y))", -2.0, 5.0, -2.0, 5.0) 17 f3=F2D("sin(4*x*y)", -2.0, 2.0, -2.0, 2.0) 18 f4=F2D("x^3-3*x-3*y^2", -2.0, 2.0, -2.0, 2.0) 19 20 21 for i in range(1000): 22 h1.fill(rand.nextGaussian(),0.5*rand.nextGaussian()) 23 h2.fill(1.0+0.5*rand.nextGaussian(),-2.0+0.5*rand.nextGaussian()) 24 25 c1.cd(1,1) 26 c1.draw(h1,h2) 27 c1.setScaling(8) 28 c1.setRotationAngle(10) 29 c1.update() 30 31 c1.cd(2,1) 32 c1.setAutoRange() 33 c1.draw(f1) 34 35 c1.cd(1,2) 36 c1.setScaling(8) 37 c1.setRotationAngle(40) 38 c1.setAutoRange() 39 c1.draw(h1) 40 41 42 c1.cd(2,2) 43 c1.setAutoRange() 44 c1.setAxesFontColor(Color.blue) 45 c1.setColorMode(4) 46 c1.setScaling(8) 47 c1.setElevationAngle(30) 48 c1.setRotationAngle(35) 49 c1.draw(f3) 50 51 c1.cd(1,3) 52 c1.setAutoRange() 53 c1.setLabelFontColor(Color.red) 54 c1.setScaling(8) 55 c1.setRotationAngle(40) 56 c1.draw(f3,f2) 57 58 c1.cd(2,3) 59 c1.setAutoRange() 60 c1.setColorMode(1) 61 c1.setScaling(8) 62 c1.setElevationAngle(30) 63 c1.setRotationAngle(35) 64 c1.draw(f4) 65 66 67 # c1.clearAll() 68 # c1.update() 69 # export to some image (png,eps,pdf,jpeg...) 70 # c1.export(Editor.DocMasterName()+".png") ### © jHepWork. S.Chekanov ### ```