 |
Histogram of X-Y points with error bars
Source code name: "canvas2D_errors_waterloo.py"
Programming language: Python
Topic: Plots/2D
DMelt Version 1. Last modified: 05/09/2015. License: Pro
https://datamelt.org/code/cache/canvas2D_errors_waterloo_7485.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 with error bars
from kcl.waterloo.swing import GCFrame
from kcl.waterloo.graphics import GJGraph,GJGraphContainer
from kcl.waterloo.graphics.plots2D import GJErrorBar,GJPlotInterface
import math
f=GCFrame()
gc=GJGraphContainer.createInstance(GJGraph.createInstance())
f.add(gc)
# show sqrt(x*x) with error bars
x=[]
y=[]
err=[]
for i in range(10):
x.append(i*4)
y.append(math.sqrt(i*i))
err.append(2)
p=GJErrorBar.createInstance()
p.setXData(x)
p.setYData(y)
p.setExtraData0(err) # right error
p.setExtraData1(err) # upper error
p.setExtraData2(err) # left error
p.setExtraData3(err) # lower error
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_errors_waterloo.svg"))
You see the box below because you did not login.