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