PsiLAB Help Manual
Page
Section:
Plot functions (1 independent dimension)
Name:
plot2d
XY plot of one or more datasets y(x) or function plots f(x) .
This function can plot datasets and functions in one display. There are several arguments controlling the way to plot the data.
plot2d
?x:(float, 'a, 'b) Matrix.t list
?y:(float, 'a, 'b) Matrix.t list
?yerr:(float, 'a, 'b) Matrix.t list
?xrange:float list
?yrange:float list
?func:(float -> float) list
?points:Plot2.pointstyle list
?lines:Plot2.linestyle list
?xlabel:string
?ylabel:string
?title:string
?legend:string list
?legpos:(float * float) list
?axis:Plot2.axisstyle
?xmajorticks:float
?xminorticks:int
?ymajorticks:float
?yminorticks:int
?symsize:float
?charsize:float
()
The x data set can either be provided with the x argument or with the xrange argument:
~x:[ x vector ]
and optionally or alone:
~xrange:[ x start; x end ]
If this argument is used in addition to the x argument, the xrange argument determines the plot range, different from the values of x .
The y dataset is put in the y list argument:
~y:[ y 1 ; y 2 ; ... ]
Like the xrange argument, a y plot range can be choosen different from the automatically determined maximum and minimum value of all y datasets:
~yrange: [ y start; y end ]
On default, all data points are conected with lines with different styles for each data set, and additionally all data points are marked in the plot with different point symbols for each data set. The way, the lines and the points are drawn, can be controlled with the linestyle and pointstyle arguments:
~lines:[ linestyle 1 ; linesytle 2 ; ... ]
The first arguments determine the functions plots if any, the last the dataset lines. The NoL type avoid lines. Only usefull for datasets.
~points:[ pointstyle 1 ; pointsytle 2 ; ... ]
Possible line styles:
type linestyle =
Solid |
Dashed |
DashDot |
Dotted |
Red |
Green |
Blue |
Violet |
NoL |
;;
Without the lines argument, the default values in the order above will be used.
Possible point styles:
type pointstyle =
Circle |
Box |
Diamond |
Triangle |
Oplus |
Odot |
Star |
FilledBox |
FilledStar |
NoP |
;;
Without the points argument, the default values in the order above will be used.
Different functions can be plotted standalone or in addition to datasets:
~func:[ function 1 ; function 2 ; ... ]
The x, the y label, and the title can be set with the arguments:
~xlabel: " string "
~ylabel: " string "
~title: " string "
To print a legend for the datasets and/or functions, use the legend and the legpos arguments:
~legend:[ " y1 " ; " y2 " ; ... ]
~legpos:[ xpos , ypos ]
The (xpos,ypos) tuple is the left upper corner of the legend box in the plot frame and both coordinates are in the range 0..1.0 in unity of the plot frame. (0.0,0.0) is the left lower corner, and (1.0,1.0) the upper right corner of the plot frame.
The elements of the line, point and legend arguments must be consistent with the number of plotted functions and datasets. Always the function elements come first, last the dataset elements:
~lines ~points ~legend :
[ fun1 ; fun2 ; ... ; ydata1 ; ydata2 ; ... ]
The axis sytle can be controlled with the axis argument:
~axis: axisstyle
with the possible settings:
type axisstyle =
NoA | (* no axis drawings *)
Pbox | (* only a box, no ticks, no values *)
LinLin | (* X:lin Y:lin axis, default *)
LinLin0 | (* additional lines at x=0 and y=0 *)
LinLinGrid | (* with grid *)
LogLin | (* X:log Y:lin axis *)
LogLinGrid |
LinLog | (* X:lin Y:log axis *)
LinLogGrid |
LogLog | (* X:log Y:log axis *)
LogLogGrid
;;
Examples:
[] let y = fmatrix ~dim:[100] ~rand:[1.0] () ;;
[] plot2d ~xrange:[1.0;100.0] ~y:[y] () ;;
[] let x = fmatrix ~fill:[1.0;100.0] () ;;
[] plot2d ~x:[x] ~y:[y] () ;;
[] plot2d ~x:[x] ~y:[y] ~points:[NoP] () ;;
[] plot2d ~x:[x] ~y:[y] ~lines:[NoL] () ;;
[] plot2d ~x:[x] ~y:[y] ~points:[NoP] ~xrange:[0.0;100.0] () ;;
[] plot2d ~x:[x] ~y:[y] ~func:[sin] ~lines:[Blue;NoL] () ;;
Printed by PsiLAB