A function (F1D) converted to H1D histogram
Source code name: "func1_histo.py"
Programming language: Python
Topic: Function/1D
DMelt Version 1. Last modified: 12/11/2015. License: Pro
https://datamelt.org/code/cache/func1_histo_1015.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
from jhplot  import *

c1 = HPlot("Canvas",700,400,2, 1)
c1.setAutoRange()
c1.setGTitle("Converting to histogram", Color.red) #put title
c1.setNameX("X")
c1.setNameY("Y")
c1.visible(1)

c1.cd(1,1)
c1.setAutoRange()
f1 = F1D("2*exp(-x*x/50)+sin(pi*x)/x", -2.0, 5.0)
c1.draw(f1)

c1.cd(2,1)
c1.setAutoRange()
c1.setNameX("X")
c1.setNameY("Y")
h=f1.getH1D()
h.setColor(Color.red)
h.setFill(1)
h.setFillColor(Color.red)
h.setErrX(0)
h.setErrY(0)
c1.draw(h)

# export to some image (png,eps,pdf,jpeg...)
# c1.export(Editor.DocMaster


You see the box below because you did not login.