Pari/GP Reference Documentation | Contents - Global index - GP keyboard shortcuts |
Functions for PostScript output High-level plotting functions Library mode Low-level plotting functions plot plotbox plotclip plotcolor plotcopy plotcursor plotdraw ploth plothraw plothsizes plotinit plotkill plotlines plotlinetype plotmove plotpoints plotpointsize plotpointtype plotrbox plotrecth plotrecthraw plotrline plotrmove plotrpoint plotscale plotstring psdraw psploth psplothraw | |
Although plotting is not even a side purpose of PARI, a number of plotting functions are provided. Moreover, a lot of people suggested ideas or submitted patches for this section of the code. There are three types of graphic functions.
| |
High-level plotting functions | |
(all the functions starting with
| |
Low-level plotting functions | |
(called rectplot functions,
sharing the prefix
A number of primitive graphic objects (called rect objects) can then
be drawn in these windows, using a default color attached to that window
(which can be changed using the
Finally, the actual physical drawing is done using
In addition to initializing the window, you may use a scaled window to
avoid unnecessary conversions. For this, use
Plotting functions are platform independent, but a number of graphical
drivers are available for screen output: X11-windows (hence also for GUI's
based on X11 such as Openwindows and Motif), and the Qt and FLTK graphical
libraries. The physical window opened by
| |
Functions for PostScript output | |
in the same way that
| |
Library mode | |
None of the graphic functions are available
within the PARI library, you must be under
| |
plot | |
Crude ASCII plot of the function represented by expression expr from a to b, with Y ranging from Ymin to Ymax. If Ymin (resp. Ymax) is not given, the minimum (resp. the maximum) of the computed values of the expression is used instead.
The library syntax is
| |
plotbox | |
Let (x1,y1) be the current position of the virtual cursor. Draw in the rectwindow w the outline of the rectangle which is such that the points (x1,y1) and (x2,y2) are opposite corners. Only the part of the rectangle which is in w is drawn. The virtual cursor does not move.
| |
plotclip | |
`clips' the content of rectwindow w, i.e remove all parts of the
drawing that would not be visible on the screen. Together with
| |
plotcolor | |
Set default color to c in rectwindow w.
This is only implemented for the X-windows, fltk and Qt graphing engines.
Possible values for c are given by the 1 = black, 2 = blue, 3 = violetred, 4 = red, 5 = green, 6 = grey, 7 = gainsborough. but this can be considerably extended.
| |
plotcopy | |
Copy the contents of rectwindow sourcew to rectwindow destw with offset (dx,dy). If flag's bit 1 is set, dx and dy express fractions of the size of the current output device, otherwise dx and dy are in pixels. dx and dy are relative positions of northwest corners if other bits of flag vanish, otherwise of: 2: southwest, 4: southeast, 6: northeast corners
| |
plotcursor | |
Give as a 2-component vector the current (scaled) position of the virtual cursor corresponding to the rectwindow w.
| |
plotdraw | |
Physically draw the rectwindows given in list which must be a vector whose number of components is divisible by 3. If list = [w1,x1,y1,w2,x2,y2,...], the windows w1, w2, etc. are physically placed with their upper left corner at physical position (x1,y1), (x2,y2),...respectively, and are then drawn together. Overlapping regions will thus be drawn twice, and the windows are considered transparent. Then display the whole drawing in a special window on your screen. If flag != 0, x1, y1 etc. express fractions of the size of the current output device
| |
ploth | |
High precision plot of the function y = f(x) represented by the expression expr, x going from a to b. This opens a specific window (which is killed whenever you click on it), and returns a four-component vector giving the coordinates of the bounding box in the form [xmin,xmax,ymin,ymax].
Important note. n specifies the number of reference point on the graph, where a value of 0 means we use the hardwired default values (1000 for general plot, 1500 for parametric plot, and 8 for recursive plot). If no flag is given, expr is either a scalar expression f(X), in which case the plane curve y = f(X) will be drawn, or a vector [f_1(X),...,f_k(X)], and then all the curves y = f_i(X) will be drawn in the same window. The binary digits of flag mean:
* 1 = For instance:
ploth(X=0,2*Pi,[sin(X),cos(X)], "Parametric") ploth(X=0,2*Pi,[sin(X),cos(X)]) ploth(X=0,2*Pi,[X,X,sin(X),cos(X)], "Parametric") draw successively a circle, two entwined sinusoidal curves and a circle cut by the line y = x.
* 2 =
ploth(X=-1,1, sin(1/X), "Recursive") ploth(X=-1,1, sin(1/X)) for instance. But beware that if you are extremely unlucky, or choose too few reference points, you may draw some nice polygon bearing little resemblance to the original curve. For instance you should never plot recursively an odd function in a symmetric interval around 0. Try
ploth(x = -20, 20, sin(x), "Recursive") to see why. Hence, it's usually a good idea to try and plot the same curve with slightly different parameters. The other values toggle various display options:
* 4 =
s = plothsizes(); plotinit(0, s[2]-1, s[2]-1); plotscale(0, -1,1, -1,1); plotrecth(0, t=0,2*Pi, [cos(t),sin(t)], "Parametric|no_Rescale") plotdraw([0, -1,1]); This way we get a proper circle instead of the distorted ellipse produced by
ploth(t=0,2*Pi, [cos(t),sin(t)], "Parametric")
* 8 =
* 16 =
* 32 =
* 64 =
* 128 =
* 256 =
* 512 =
* 1024 =
* 2048 =
* 4096 =
ploth(X=0,2*Pi,exp(I*X), "Complex") ploth(X=0,2*Pi,[(1+I)*X,exp(I*X)], "Complex") will draw respectively a circle and a circle cut by the line y = x.
| |
plothraw | |
Given listx and listy two vectors of equal length, plots (in
high precision) the points whose (x,y)-coordinates are given in
listx and listy. Automatic positioning and scaling is done, but
with the same scaling factor on x and y. If flag is 1, join points,
other non-0 flags toggle display options and should be combinations of bits
2^k, k ≥ 3 as in
| |
plothsizes | |
Return data corresponding to the output window
in the form of a 6-component vector: window width and height, sizes for ticks
in horizontal and vertical directions (this is intended for the If flag = 0, sizes of ticks and characters are in pixels, otherwise are fractions of the screen size
| |
plotinit | |
Initialize the rectwindow w, destroying any rect objects you may have already drawn in w. The virtual cursor is set to (0,0). The rectwindow size is set to width x and height y; omitting either x or y means we use the full size of the device in that direction. If flag = 0, x and y represent pixel units. Otherwise, x and y are understood as fractions of the size of the current output device (hence must be between 0 and 1) and internally converted to pixels.
The plotting device imposes an upper bound for x and y, for instance the
number of pixels for screen output. These bounds are available through the
s = plothsizes(); plotinit(0, s[1]-1, s[2]-1); plotscale(0, 0,1000, 0,1000);
| |
plotkill | |
Erase rectwindow w and free the corresponding memory. Note that if you
want to use the rectwindow w again, you have to use
| |
plotlines | |
Draw on the rectwindow w the polygon such that the (x,y)-coordinates of the vertices are in the vectors of equal length X and Y. For simplicity, the whole polygon is drawn, not only the part of the polygon which is inside the rectwindow. If flag is non-zero, close the polygon. In any case, the virtual cursor does not move.
X and Y are allowed to be scalars (in this case, both have to).
There, a single segment will be drawn, between the virtual cursor current
position and the point (X,Y). And only the part thereof which
actually lies within the boundary of w. Then move the virtual cursor
to (X,Y), even if it is outside the window. If you want to draw a
line from (x1,y1) to (x2,y2) where (x1,y1) is not necessarily the
position of the virtual cursor, use
| |
plotlinetype | |
This function is obsolete and currently a no-op. Change the type of lines subsequently plotted in rectwindow w. type -2 corresponds to frames, -1 to axes, larger values may correspond to something else. w = -1 changes highlevel plotting.
| |
plotmove | |
Move the virtual cursor of the rectwindow w to position (x,y).
| |
plotpoints | |
Draw on the rectwindow w the
points whose (x,y)-coordinates are in the vectors of equal length X and
Y and which are inside w. The virtual cursor does not move. This
is basically the same function as
As was the case with the
| |
plotpointsize | |
This function is obsolete. It is currently a no-op. Changes the "size" of following points in rectwindow w. If w = -1, change it in all rectwindows.
| |
plotpointtype | |
This function is obsolete and currently a no-op. change the type of points subsequently plotted in rectwindow w. type = -1 corresponds to a dot, larger values may correspond to something else. w = -1 changes highlevel plotting.
| |
plotrbox | |
Draw in the rectwindow w the outline of the rectangle which is such that the points (x1,y1) and (x1+dx,y1+dy) are opposite corners, where (x1,y1) is the current position of the cursor. Only the part of the rectangle which is in w is drawn. The virtual cursor does not move.
| |
plotrecth | |
Writes to rectwindow w the curve output of
| |
plotrecthraw | |
Plot graph(s) for
data in rectwindow w. flag has the same significance here as in
data is a vector of vectors, each corresponding to a list a coordinates. If parametric plot is set, there must be an even number of vectors, each successive pair corresponding to a curve. Otherwise, the first one contains the x coordinates, and the other ones contain the y-coordinates of curves to plot.
| |
plotrline | |
Draw in the rectwindow w the part of the segment (x1,y1)-(x1+dx,y1+dy) which is inside w, where (x1,y1) is the current position of the virtual cursor, and move the virtual cursor to (x1+dx,y1+dy) (even if it is outside the window).
| |
plotrmove | |
Move the virtual cursor of the rectwindow w to position (x1+dx,y1+dy), where (x1,y1) is the initial position of the cursor (i.e. to position (dx,dy) relative to the initial cursor).
| |
plotrpoint | |
Draw the point (x1+dx,y1+dy) on the rectwindow w (if it is inside w), where (x1,y1) is the current position of the cursor, and in any case move the virtual cursor to position (x1+dx,y1+dy).
| |
plotscale | |
Scale the local coordinates of the rectwindow w so that x goes from
x1 to x2 and y goes from y1 to y2 (x2 < x1 and y2 < y1 being
allowed). Initially, after the initialization of the rectwindow w using
the function
| |
plotstring | |
Draw on the rectwindow w the String x (see Section se:strings), at the current position of the cursor. flag is used for justification: bits 1 and 2 regulate horizontal alignment: left if 0, right if 2, center if 1. Bits 4 and 8 regulate vertical alignment: bottom if 0, top if 8, v-center if 4. Can insert additional small gap between point and string: horizontal if bit 16 is set, vertical if bit 32 is set (see the tutorial for an example).
| |
psdraw | |
Same as
| |
psploth | |
Same as
| |
psplothraw | |
Same as
| |