Function:s2errb
From S2PLOT
s2errb
Draw error bars at the coordinates (xpts[i], ypts[i], zpts[i]).
Prototype
void s2errb(int dir, int n, float *xpts, float *ypts, float *zpts, float *edelt, int termsize);
Description
Draw error bars at the coordinates (xpts[i], ypts[i], zpts[i]). Error bars are drawn in the direction indicated by argument dir as described below. One-sided error bar lengths are given by edelt, such that for error bars in eg. the x direction, error bars are drawn to xpts[i]+edelt[i], to xpts[i]-edelt[i], or to both. Argument termsize gives the size of the terminals to draw for each error bar; it is given in an integer increment of the current linewidth. Eg. if t=1, then end points are one pixel larger than the line width used to draw the bars.
dir: 1 | for error bar in | +x | direction |
2 | ... | +y | ... |
3 | ... | +z | ... |
4 | ... | -x | ... |
5 | ... | -y | ... |
6 | ... | -z | ... |
7 | ... | +/-x | ... |
8 | ... | +/-y | ... |
9 | ... | +/-z | ... |
PGPLOT Equivalent
Code Example
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "s2plot.h"
/* A modified version of sample progam s2uc1.c */
int main(int argc, char *argv[])
{
int i;
float np = 100; /* point population size */
float *xpts, *ypts, *zpts; /* point positions */
float *expts,*eypts,*ezpts; /* error bar lengths */
int symbol = 0; /* -2 = infinitesimally small dot */
float x1 = -100.0, x2 = +100.0;
float y1 = -100.0, y2 = +100.0;
float z1 = -100.0, z2 = +100.0;
s2opend("/?",argc,argv);
/* set world coordinate range */
s2swin(x1,x2, y1,y2, z1,z2);
/* generate a set of points extending over world coordinate space */
xpts = (float *)calloc(np, sizeof(float));
ypts = (float *)calloc(np, sizeof(float));
zpts = (float *)calloc(np, sizeof(float));
expts = (float*)calloc(np, sizeof(float));
eypts = (float*)calloc(np, sizeof(float));
ezpts = (float*)calloc(np, sizeof(float));
for (i = 0; i < np; i++) {
xpts[i] = x1 + (float)(rand()) / (float)RAND_MAX * (x2 - x1);
ypts[i] = y1 + (float)(rand()) / (float)RAND_MAX * (y2 - y1);
zpts[i] = z1 + (float)(rand()) / (float)RAND_MAX * (z2 - z1);
expts[i]=(float)(rand()) / (float)RAND_MAX * (x2-x1)*0.05;
eypts[i]=fabsf(ypts[i]) * 0.1;
ezpts[i]= (z2-z1)*0.1;
}
/* plot red points */
s2sci(S2_PG_RED);
s2pt(np, xpts, ypts, zpts, symbol);
/* plot various error bars */
s2sci(S2_PG_WHITE);
s2errb(4, np, xpts, ypts, zpts, expts, 1);
s2sci(S2_PG_GREEN);
s2errb(2, np, xpts, ypts, zpts, eypts, 2);
s2sci(S2_PG_ORANGE);
s2errb(9, np, xpts, ypts, zpts, ezpts, 3);
/* draw and label a box around the points, in white */
s2sci(S2_PG_WHITE);
s2box("BCDET",0,0,"BCDET",0,0,"BCDET",0,0);
s2show(1);
return 0;
}
Back to S2PLOT function list.