Satimage Previous | Next
The curve
Home Documentation SmileLab Scripting Graphic objects Graphic view Plot view The curve  
Table of contents
curve is the class of the objects that a plot view can contain. curves can display sets of (x, y) pairs and graphs of functions.
curves necessarily belong to plot views. If you attempt to create a curve alone you get an error message.
set c to make new curve --> ERROR: Unknown object type
set w to make new graphic window
set v to make new plot view at w
set c to make new curve at v -- correct
Providing the curve with data
xdata, ydata, errorbar data and formula are the properties of the curve that you manipulate to define what data it will plot.
xdata and ydata
To plot a set of (x,y) pairs provide two lists of identical size of real numbers, or two arrays of real of identical size, as the xdata and ydata properties of the curve.
set x to runningsum (randomarray 20)
set y to runningsum x
set xdata of c to x
set ydata of c to y
draw w
errorbar data
To plot error bars, provide an arrays of real as the errorbar data property. If this array has twice the number of elements as xdata, the error bars (up and down) at the nth point will have the lengths defined by the values of the (2n-1)th and the 2nth elements of errorbar data. Else if this array has the same number of elements as xdata, both error bars (up and down) at each point will have the same length.
To plot the graph of a function, provide a string that describes a function of the x variable as the formula property of the curve.
set cc to make new curve at v
set formula of cc to "x*x"
draw w
By default, if xdata is not defined the curve plots 100 samples. To change the sampling, provide a different number of samples as the step property. To retrieve the default behavior set step to 0.0.

formula has priority over ydata: if formula is not the empty string "" the curve does not consider the ydata property.

Graphic options for the curve
Curve vs scatter plot
In SmileLab the same curve object plots curves and scatter plots.
By default the curve performs a simple line plot and its settings are as follows:
  • line style is set to 1 ("line")
  • pattern style is set to 0 ("none")
  • antialiasing is set to true.
For a scatter plot, set the properties of the curve as follows:
  • set line style to 0 ("none")
  • set pattern style to 1 ("circle") or, for optimal speed, to 8 ("dot")
  • set antialiasing to false.
When the data to plot are really numerous (more than thousands), the latter settings are how you get the fastest rendering.
Other options
line style
You can set the line style property to 2 in order to display a smooth curve. Please note, the smoothing algorithm is adapted only for a list of 2D points with increasing abscissae.
pattern style
The valid values for pattern style (the symbol that displays each (x,y) pair) are: 0 = none, 1 = circle, 2 = square, 3 = diamond, 4 = upwards triangle, 5 = downwards triangle, 6 = x-cross, 7 = cross, 8 = dot, 9 = custom, 10 = vertical bar. If you set pattern style to 9 you may define an arbitrary polygon as the pattern. Provide the pattern, as a list {x1, y1,...,xn, yn} of the coordinates (in pixels) of the vertices of the polygon, into the custom pattern property. If you do not use custom patterns, you do not need to set custom pattern.
set line style of c to 0
set pattern style of c to 3
set pattern size of c to 4
set pen color of c to {0, 0, 1}
set fill color of c to {1, 1, 1, 0}
set pen width of c to 2
set pen width of cc to 2
draw w
pattern size
Whatever pattern you choose, you can change its size by assigning a new value (in pixels) to the pattern size property.
fill color
The pattern uses the fill color property of the curve as the color for its inner area (for instance the circle's interior).
pen color
The pattern's boundary (for instance the circumference of the circle) and the curve itself - if line style is set to 1 or 2 - use the pen color property as their color and the pen width property (in pixels) as their stroke thickness.
The curve uses the (optional) dash property do define its dash pattern. For a description of the conventions for the dash property please refer to the instructions for the chart view's grid dash property (in The chart view object).
The antialiasing boolean property defines whether SmileLab will produce an enhanced rendering by applying antialiasing, it is set to true by default.
in legend
Each curve of a given plot view can be displayed or not in the plot view's legend - when the plot view's legend mode is set to "legend in a frame" - and it can display its name or not on its plot - when the plot view's legend mode is set to "legend on curve". This is what the boolean in legend property specifies.
Copyright ©2008 Paris, Satimage