from java.awt import *
from jhplot import * 
from jhplot.shapes  import *
from java.util import Random

c1 =HPlot("Canvas",600,400)
c1.setGTitle("Data and shapes")
c1.setAntiAlias(1)
c1.setLegend(0)
c1.setNameX("X")
c1.setNameY("Y")
c1.setRange(-4.0, 4.0, 0.0, 20.0)
c1.visible(1)

p1=P1D("data")
p1.add(-1,11) # mak center of the ellipse

h1 = H1D("Histogram",50, -4, 4.0)
rand = Random()
for i in range(100):
      h1.fill(rand.nextGaussian())  
      p1.add(  0.8*rand.nextGaussian()+3,   0.5*rand.nextGaussian()+15)
      
# filled eclipse
ele1= Ellipse(-1, 11.0, 2,5) # ellipse at(1,5) with major 10, minor 5
ele1.setFill(1)
ele1.setRotation(3.14/4)
ele1.setColor(Color.green)
ele1.setTransparency(0.5)
c1.add(ele1)

ele2= Ellipse(-1,11.0, 2,5) # ellipse at(1,5) with major 10, minor 5
ele2.setFill(1)
ele2.setRotation(0)
ele2.setColor(Color.blue)
ele2.setTransparency(0.2)
c1.add(ele2)

ele3= Ellipse(-1,11.0, 1,3) # ellipse at(1,5) with major 10, minor 5
ele3.setFill(0)
ele3.setRotation(0.2)
ele3.setColor(Color.red)
ele3.setTransparency(0.2)
c1.add(ele3)

# set HLabel in the USER coordinate system
lab=HLabel("Data and shapes", 1, 18)
c1.add(lab)

# now show all objects
c1.draw(p1)
c1.draw(h1)

# export to some image (png,eps,pdf,jpeg...)
# c1.export(Editor.DocMasterName()+".png");

