simplot library

overview of available routines

Simplot is a plot package, especially designed for C programmers. It also contains a simplot program for use by those having no programming experience at all. A very simple program, let's call it simple.c, looks like this:

#include <simplot.h>

int main(void) {
   plinit(X,"",200,200,15,15,"","");
   plloop();
   exit(0);
}
This program simply displays an X window of 200 x 200 millimeters, which has the origin at 15 mm from the left side and 15 mm from the bottom. It makes use of the default plevent routine, which recognises only a few interactions: the key stroke q ends your program, and the left mouse button displays cross hairs and their (x,y) position. The window also shows one button `Quit', which you can click with obvious results. Assuming that you installed Simplot in the default location, /simplot, you can compile this program with:
cc -I/usr/openwin/include \
   -I/simplot/include \
   -c -o simple.o simple.c

cc -L/simplot/lib \
   -L/usr/openwin/lib \
   -L/usr/X11R6/lib \
   -lsimplot -lxview -lolgx -lX11 -lm \
   -o simple simple.o \
You can make your own plevent routine to have more functionality. Here is an example:
#include <simplot.h>

void plevent(float x, float y, int key) {
   static float xx,yy;
   static int leftdown=FALSE;
   switch(key) {
      case 'q':
         plend();
         exit(0);
         break;
      case MouseMiddleDown:
         plmess("%g %g",x,y);
         plhairs(x,y,TRUE,TRUE);
         break;
      case MouseLeftDown:
         leftdown=TRUE;
         plmess("%g %g",x,y);
         plu(xx=x,yy=y);
         break;
      case MouseDrag:
         plmess("%g %g",x,y);
         if (leftdown) {
    	   plu(xx,yy);
	   pld(xx=x,yy=y);
         } else {
           plhairs(x,y,TRUE,TRUE);
         }
         break;
      case MouseLeftUp:
      case MouseMiddleUp:
         leftdown=FALSE;
         plhairs(x,y,FALSE,FALSE);
         plmess("");
         break;
   }
}

int main(void) {
   plinit(X,"",200,200,15,15,"","");
   plloop();
   exit(0);
}
This program shows the same cross hairs as the previous example, but in this case on pressing the middle mouse button. The left button now lets you draw free-hand curves. Here is an overview of all Simplot's routines; click on the routine names for full detail:

aplarc xcenter,ycenter,radius,start_angle,arc ,line_style
plot an arc using user units
plarcm xcenter,ycenter,radius,start_angle,arc ,line_style
plot an arc using user units
plarcr dxcenter,dycenter,arc ,line_style
plot an arc relative to the current position, in user units
plarcrm dxcenter,dycenter,arc ,line_style
plot an arc relative to the current position, in millimeter units
plarrow dx,dy,len_pointer,ang_small,ang_large ,both_ends ,open,filled,perpendicular ,*text
plot an annotated arrow
plaxes xleft,ybot,xright,ytop,xlen,ylen ,*xtext,*ytext,*text
plot x-- and y--axes, more or less automatically
plaxfit *x,*y ,n ,dpercent,xlen,ylen ,*xtext,*ytext,*text
plot axes, fitted to an (x,y) array
bplblock x1,y1,z1,x2,y2,z2
plot a 3D-block in user units
plblockm x1,y1,z1,x2,y2,z2
plot a 3D-block in millimeter units
plbox x1,y1,x2,y2,radius
plot a box with rounded corners in user units
plboxm x1,y1,x2,y2,radius
plot a box with rounded corners in millimeter units
plbutton *label ,(*func )()
create a button in an X-display
cplclip x1,y1,x2,y2
set clipping rectangle in user units
plclipm x1,y1,x2,y2
set clipping rectangle in millimeter units
plcont *xy,*x,*y ,nx,ny,nxa ,height ,*ident ,line_style ,*flag
plot contours in an (x,y) array
plcolor red,green,blue
set the current color
dpld x,y
draw a straight line to a position in user units
pldm x,y
draw a straight line to a position in millimeter units
pldot x,y
plot a dot with diameter equal to current linewidth in user units
pldotm x,y
plot a dot with diameter equal to current linewidth in millimeter units
pldraw (void)
the user's drawing routine; (re)draws everything
eplend (void)
end plotting session
plevent xpointer,yointer ,event_code
handle X-events
plexit *message
print a message to standard error and exit
pleye xeye,yeye,zeye,xfocus,yfocus,zfocus
define location and focus of the eye in a 3D plot in user units
pleyem xeye,yeye,zeye,xfocus,yfocus,zfocus
define location and focus of the eye in a 3D plot in millimeter units
fplfill fill_red,fill_green,fill_blue,stroke_red,stroke_green,stroke_blue
fill and/or stroke the current path
plfcolor fill_red,fill_green,fill_blue
set fill_color for filled objects
plfont (void)
toggle between primary and alternate font
plformat left_right,up_down ,*format...
plot text according to extended C-format string with justification
plframe distance ,radius
draw a (rounded) box around current plot
plfunc (*func)(xf),xmin,ymin,xmax,ymax ,line_style
plot a 2D function
gplget name
return the value of a global variable
hplhairs x,y ,horizontal,vertical
(re)display or clear horizontal and/or vertical hairs in an X-application
plhiss *x,*y ,n,type,baseline ,ybase ,line_style ,ang,dis ,icshad
plot shaded histogram
plhist *x,*y ,n,type,baseline ,ybase
plot histogram or stick plot
iplinit drvr ,*file ,xsize,ysize ,*main_font,*alternate_font
initialize the plot-system
lplloop (void)
start event loop
mplmess *format...
display a formatted message
plmvorg x,y
move the origin in user units
plmvorgm x,y
move the origin in millimeter units
oplot x,y ,line_style
move the pen to a new 2D position in user units
plotm x,y ,line_style
move the pen to a new 2D position in millimeter units
plot3 x,y,z ,line_style
move the pen to a new 3D position in user units
plotm3 x,y,z ,line_style
move the pen to a new 3D position in millimeter units
plotr x,y ,line_style
move the pen to a new relative 2D position in user units
plotrm x,y ,line_style
move the pen to a new relative 2D position in millimeter units
plotr3 x,y,z ,line_style
move the pen to a new relative 3D position in user units
plotrm3 x,y,z ,line_style
move the pen to a new relative 3D position in millimeter units
pplpage (void)
feed a new page / clear the screen
plpgon *x,*y ,n,filltype ,spacing,angle ,line_style,last
plot a (filled) polygon
plpie **label ,n,lablen ,radius,x,y ,*toptext ,topfac ,*bottext ,botfac
plot an annotated pie
plpline *x,*y ,n ,*marker ,dash
plot a 2D polyline
plpline3 *x,*y,*z ,n,isym
plot a 3D polyline
plpolar size,angle ,pen
plot e vector in polar coordinates in user units
plpolarm size,angle ,pen
plot e vector in polar coordinates in millimeter units
plpolc *p
retrieve the coefficients of the current polynomial
plpolf *x,*y ,n,kk
calculate a polynomial
plpolv x
evaluate the current polynomial in x
plpoly *x,*y ,n,kk ,xmin,xmax ,line_style
calculate and plot a polynomial
rplrect x1,y1,x2,y2
plot a (filled) rectangle in user units
plrectm x1,y1,x2,y2
plot a (filled) rectangle in millimeter units
plrectr dx,dy
plot a (filled) relative rectangle in user units
plrectrm dx,dy
plot a (filled) relative rectangle in millimeter units
pldraw (void)
user-defined routine redrawing the canvas in X-applications
plreserv xrg,yrg,yhigh
move origin for concatenation of sub-plots
plrotate dx,dy
rotate user coordinate system
splsave (void)
save current graphics context
plscale3 xmin,ymin,zmin,xmax,ymax,zmax,xlen,ylen,zlen
define 3D scaling factors
plset name ,value
set global values
plshade *xvert,*yvert ,nvert ,dir,wmesh ,line_style
hatch polygon
plsize *s
return the length of a string plotted in the current font
plsmooth *a ,n,k
perform k-point smoothing on (x,y) array
plsort *x,*y ,n
sort (x,y) array
plsymbol isym
plot a symbol
tpltext0 *text
plot a string, returning to position
pltext *s
plot a string, leave pen at end
pltrace (*f)(x,y),xmin,ymin,xmax,ymax,resol,grid ,*ident ,line_style
track an (implicit) 2D function
uplu[m] x,y
move to position without plotting in user units
plu[m] x,y
move to position without plotting in user units
plunclip (void)
remove clipping
plunsave (void)
restore graphics context
xplxbar v
plot error bar in x-direction
yplybar v
plot error bar in x-direction

Predefined names are:

A0 A1 A2 A3
A4 A5 A6 A7
ANGLE ArrowDown ArrowLeft ArrowRight
ArrowUp CROSS DASH DASHUNIT
DOWN Delete EVENT_ASCII EVENT_BUTTON
EVENT_DOWN EVENT_FUNCTION EVENT_UP End
Escape F1 F10 F11
F12 F2 F3 F4
F5 F6 F7 F8
F9 GXcopy GXxor HEIGHT
Home Insert LEVENTS MouseDrag
MouseLeftDown MouseLeftUp MouseMiddleDown MouseMiddleUp
MouseRightDown MouseRightUp OPAQUETEXT PDF
PDFL PENDIA PLOTMODE PLOTTER
preCISION PS PSL
PageDown PageUp RECTFILL RECTSTROKE
RESOLUTION UP X XANGLE
XCROSS XGRID XIN XLOG
XMARK XPEN XSIZE XSKIP
XSQUAR XU2M XU2P YANGLE
YCROSS YGRID YIN YLOG
YMARK YPEN YSIZE YSKIP
YSQUAR YU2M YU2P