Showx X-Y values with statistical and systematic errors
Source code name: "p1d_points.py"
Programming language: Python
Topic: Data arrays/P1D
DMelt Version 1. Last modified: 12/08/2015. License: Free
https://datamelt.org/code/cache/p1d_points_8276.py
To run this script using the DMelt IDE, copy the above URL link to the menu [File]→[Read script from URL] of the DMelt IDE.



from java.awt import Color,Font
from java.util import Random
from jhplot  import HPlot,H1D,P1D
from math  import sqrt

c1 = HPlot("Canvas",700,400,2,1)

p1= P1D("test 1")
p2= P1D("test 2")
p3= P1D("test 3")
p4= P1D("test 4")

c1.setGTitle("Example of symbols", Color.blue) #put title
c1.viewHisto(0)  # make sure starts from 0
c1.visible(1)
c1.setAutoRange()


# fill
rand = Random() 
for i in range(10):
      x=4.0*i # x-value
      y=20.0*i+10.0*rand.nextGaussian() # y-value
      xLeft=3.5
      xRight=3.5
      xLeftSys=2.0
      xRightSys=2.0
      yUpper=5.0
      if y>0: yUpper=sqrt(y)
      yLower=yUpper
      yUpperSys=4.5 
      xLowerSys=4.5
      p1.add(x,y,xLeft,xRight,yUpper,yLower,xLeftSys,xRightSys,yUpperSys,xLowerSys);
      p2.add(2*x,4*y,xLeft,xRight,5*yUpper,5*yLower,xLeftSys,xRightSys,20.0*yUpperSys,20.0*xLowerSys);
      p3.add(x,8*y,xLeft,xRight,20*yUpper,20*yLower,xLeftSys,xRightSys,50*yUpperSys,50*xLowerSys);
      p4.add(2*x,12*y,xLeft,xRight,20*yUpper,30*yLower,xLeftSys,xRightSys,30*yUpperSys,30*xLowerSys);

p1.setStyle("p")
p1.setErrAll(1)
p1.setColor(Color.red)
p1.setSymbolSize(4)

c1.cd(1,1)
c1.draw(p1)
p2.setSymbol(5)
p2.setErrAll(1)
c1.setNameX("Fig.1")
c1.setNameY("Yaxis");
c1.draw(p2)

c1.cd(2,1)
c1.setAutoRange()
p3.setSymbol(4)
p2.setErrAll(1)
p3.setColor(Color.blue)
p3.setSymbolSize(6)
c1.draw(p3)
p4.setSymbol(4)
c1.draw(p4)
     
h1 = H1D("e^{+}e^{-} → W^+{}W^{-} → 4 jets",6, 50.0, 100.0)
rand = Random()
# fill histogram
for i in range(2000):
      h1.fill(100+10*rand.nextGaussian())

h1.setFill(1)
h1.setFillColor(Color.green)
h1.setColor(Color.green)
h1.setErrX(0)
h1.setErrY(1)
h1.setPenWidthErr(2)
c1.setLogScale(0,0)
c1.setNameX("Fig.2")
c1.setNameY("Yaxis");
c1.draw(h1)


# export to some image (png,eps,pdf,jpeg...)
# c1.export(Editor.DocMasterName()+".png")