Histogram of X-Y points using Waterloo scientific library
Source code name: "canvas2D_histo_waterloo.py"
Programming language: Python
Topic: Plots/2D
DMelt Version 1. Last modified: 05/09/2015. License: Pro
https://datamelt.org/code/cache/canvas2D_histo_waterloo_3736.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.


# This example shows how to plot X-Y using Waterloo scientific library 

from kcl.waterloo.swing import GCFrame
from kcl.waterloo.graphics import GJGraph,GJGraphContainer
from kcl.waterloo.graphics.plots2D import GJBar,GJPlotInterface
import math

f=GCFrame()
gc=GJGraphContainer.createInstance(GJGraph.createInstance())
f.add(gc)

# show sqrt(x*x) histogram
x=[]
y=[]
for i in range(50):
      x.append(i)
      y.append(math.sqrt(i*i))

p=GJBar.createInstance()
p.setXData(x)
p.setYData(y)

gc.getView().add(p)
gc.getView().autoScale()

print "Creating SVG image.."
from kcl.waterloo.export import ExportFactory
from java.io import File
ExportFactory.saveAsSVG(gc, File("canvas2D_histo_waterloo.svg"))


You see the box below because you did not login.