-
Notifications
You must be signed in to change notification settings - Fork 67
GraphErrors
Will Phelps edited this page May 5, 2017
·
3 revisions
This example shows how to properly use GraphErrors objects. These
double barberx[] = {3.95,4.05,4.15,4.25,4.35,4.45,4.55,4.65,4.75};
double barbery[] = {.8,3.1,10.0,29.8,31.2,42.5,28.5,39.8,29.7};
double barberyerr[] = {0.0,2.0,4.0,6.0,6.5,8.0,6.0,7.0,6.5};
double bodenkampx[] = {((5.102+4.740)/2.0),((5.464+5.102)/2.0),((5.464+5.826)/2.0),((5.826+6.188)/2.0),((6.188+6.550)/2.0)};
double bodenkampy[] = {75.8,82.1,65.0,89.6,84.9};
double bodenkampyerr[] = {13.4,16.7,13.5,17.5,15.7};
JFrame frame = new JFrame("Basic GROOT Demo 2");
EmbeddedCanvas canvas = new EmbeddedCanvas();
frame.setSize(1200,750);
GraphErrors barber = new GraphErrors();
GraphErrors bodemkamp = new GraphErrors();
for(int i=0; i< barberx.length; i++){
barber.addPoint(barberx[i], barbery[i], 0, barberyerr[i]);
}
for(int i=0; i< bodenkampx.length; i++){
bodemkamp.addPoint(bodenkampx[i], bodenkampy[i], 0, bodenkampyerr[i]);
}
barber.setTitleX("E#gamma [GeV]");
barber.setTitleY("#sigma [nb]");
canvas.getPad(0).setTitle("Total Cross Section #gammap#rarrowpppbar");
canvas.draw(barber);
canvas.draw(bodemkamp,"same");
canvas.setFont("HanziPen TC");
canvas.setTitleSize(48);
canvas.setAxisTitleSize(32);
canvas.setAxisLabelSize(28);
canvas.setStatBoxFontSize(18);
frame.add(canvas);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
Here's how to set the marker style, color, line color, and size.
Marker styles are as follows: 0=Circle,1=Square,2=Triangle,3=Inverted Triangle
barber.setMarkerColor(2);
barber.setLineColor(2);
barber.setMarkerStyle(0);
barber.setMarkerSize(7);
barber.setLineThickness(3);
bodemkamp.setMarkerColor(4);
bodemkamp.setLineColor(4);
bodemkamp.setMarkerStyle(0);
bodemkamp.setMarkerSize(7);
bodemkamp.setLineThickness(3);