Pari/GP Reference Documentation | Contents - Index - Meta commands |
plot plotbox plotclip plotcolor plotcopy plotcursor plotdraw plotfile ploth plothraw plothsizes plotinit plotkill plotlines plotlinetype plotmove plotpoints plotpointsize plotpointtype plotrbox plotrecth plotrecthraw plotrline plotrmove plotrpoint plotscale plotstring plotterm psdraw psploth psplothraw | |
plot(X = a,b,expr,{Ymin},{Ymax}) | |
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 minima (resp. the maxima) of the computed values of the expression is used instead. | |
plotbox(w,x2,y2) | |
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(w) | |
`clips' the content of rectwindow w, i.e remove all parts of the drawing that would not be visible on the screen. Together with plotcopy this function enables you to draw on a scratchpad before commiting the part you're interested in to the final picture. | |
plotcolor(w,c) | |
set default color to c in rectwindow w. In present version 2.1.1, this is only implemented for X11 window system, and you only have the following palette to choose from: 1 = black, 2 = blue, 3 = sienna, 4 = red, 5 = cornsilk, 6 = grey, 7 = gainsborough. Note that it should be fairly easy for you to hardwire some more colors by tweaking the files rect.h and plotX.c. User-defined colormaps would be nice, and may be available in future versions. | |
plotcopy(w1,w2,dx,dy) | |
copy the contents of rectwindow w1 to rectwindow w2, with offset (dx,dy). | |
plotcursor(w) | |
give as a 2-component vector the current (scaled) position of the virtual cursor corresponding to the rectwindow w. | |
plotdraw(list) | |
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. | |
plotfile(s) | |
set the output file for plotting output. Special filename - redirects to the same place as PARI output. | |
ploth(X = a,b,expr,{flag = 0},{n = 0}) | |
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: Since this may involve a lot of function calls, it is advised to keep the current precision to a minimum (e.g.9) before calling this function. n specifies the number of reference point on the graph (0 means use the hardwired default values, that is: 1000 for general plot, 1500 for parametric plot, and 15 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: parametric plot. Here expr must be a vector with an even number of components. Successive pairs are then understood as the parametric coordinates of a plane curve. Each of these are then drawn. For instance: ploth(X = 0,2*Pi,[sin(X),cos(X)],1) will draw a circle. ploth(X = 0,2*Pi,[sin(X),cos(X)]) will draw two entwined sinusoidal curves. ploth(X = 0,2*Pi,[X,X,sin(X),cos(X)],1) will draw a circle and the line y = x. * 2: recursive plot. If this flag is set, only one curve can be drawn at time, i.e.expr must be either a two-component vector (for a single parametric curve, and the parametric flag has to be set), or a scalar function. The idea is to choose pairs of successive reference points, and if their middle point is not too far away from the segment joining them, draw this as a local approximation to the curve. Otherwise, add the middle point to the reference points. This is very fast, and usually more precise than usual plot. Compare the results of ploth(X = -1,1,sin(1/X),2) and 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), 2) 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: do not rescale plot according to the computed extrema. This is meant to be used when graphing multiple functions on a rectwindow (as a plotrecth call), in conjuction with plotscale. * 8: do not print the x-axis. * 16: do not print the y-axis. * 32: do not print frame. * 64: only plot reference points, do not join them. * 256: use splines to interpolate the points. * 512: plot no x-ticks. * 1024: plot no y-ticks. * 2048: plot all ticks with the same length. | |
plothraw(listx,listy,{flag = 0}) | |
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 ploth. | |
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 gnuplot interface and is currently not significant), width and height of characters. | |
plotinit(w,x,y) | |
initialize the rectwindow w to width x and height y, and position the virtual cursor at (0,0). This destroys any rect objects you may have already drawn in w. 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 plothsizes function. The following sequence initializes in a portable way (i.e independant of the output device) a window of maximal size, accessed through coordinates in the [0,1000] x [0,1000] range:
s = plothsizes(); plotinit(0, s[1]-1, s[2]-1); plotscale(0, 0,1000, 0,1000); | |
plotkill(w) | |
erase rectwindow w and free the corresponding memory. Note that if you want to use the rectwindow w again, you have to use initrect first to specify the new size. So it's better in this case to use initrect directly as this throws away any previous work in the given rectwindow. | |
plotlines(w,X,Y,{flag = 0}) | |
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 plotmove(w,x1,y1) before using this function. | |
plotlinetype(w,type) | |
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. This is only taken into account by the gnuplot interface. | |
plotmove(w,x,y) | |
move the virtual cursor of the rectwindow w to position (x,y). | |
plotpoints(w,X,Y) | |
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 plothraw, but either with no scaling factor or with a scale chosen using the function plotscale. As was the case with the plotlines function, X and Y are allowed to be (simultaneously) scalar. In this case, draw the single point (X,Y) on the rectwindow w (if it is actually inside w), and in any case move the virtual cursor to position (x,y). | |
plotpointsize(w,size) | |
changes the "size" of following points in rectwindow w. If w = -1, change it in all rectwindows. This only works in the gnuplot interface. | |
plotpointtype(w,type) | |
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. This is only taken into account by the gnuplot interface. | |
plotrbox(w,dx,dy) | |
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(w,X = a,b,expr,{flag = 0},{n = 0}) | |
writes to rectwindow w the curve output of ploth(w,X = a,b,expr,flag,n). | |
plotrecthraw(w,data,{flag = 0}) | |
plot graph(s) for data in rectwindow w. flag has the same significance here as in ploth, though recursive plot is no more significant. 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 containe the x coordinates, and the other ones contain the y-coordinates of curves to plot. | |
plotrline(w,dx,dy) | |
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(w,dx,dy) | |
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(w,dx,dy) | |
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(w,x1,x2,y1,y2) | |
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 plotinit, the default scaling is the graphic pixel count, and in particular the y axis is oriented downwards since the origin is at the upper left. The function plotscale allows to change all these defaults and should be used whenever functions are graphed. | |
plotstring(w,x,{flag = 0}) | |
draw on the rectwindow w the String x (see Section (??)), 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). | |
plotterm(term) | |
sets terminal where high resolution plots go (this is currently only taken into account by the gnuplot graphical driver). Using the gnuplot driver, possible terminals are the same as in gnuplot. If term is "?", lists possible values. Terminal options can be appended to the terminal name and space; terminal size can be put immediately after the name, as in "gif = 300,200". Positive return value means success. | |
psdraw(list) | |
same as plotdraw, except that the output is a PostScript program appended to the psfile. | |
psploth(X = a,b,expr) | |
same as ploth, except that the output is a PostScript program appended to the psfile. | |
psplothraw(listx,listy) | |
same as plothraw, except that the output is a PostScript program appended to the psfile. | |