1-D Function plots
VectSharp.Plots can be used to create function plots, i.e. plots showing the value of a function over a range of its arguments. To create a plot for a function of one variable, you can use the Plot.Create.Function
method:
This method has five overloads, two of which are used to plot functions of one variable. One overload’s first argument is a Func<double, double>
delegate (i.e., a function taking a single double
argument and returning a double
, which is the one used in the example above), while the other has as a first argument an IReadOnly<Func<double, double>>
(i.e., a collection of functions). The first overload plots a single function, while the second overload plots multiple functions one over the other. Both overloads have two additional required parameters, double min
and double max
, which define the range of arguments over which the function is plotted.
Other optional parameters can be used to determine the appearance of some elements of the plot. Many of these are in common with other kinds of plots and are described in the page about scatter plots; here are the ones specific for function plots:
double resolution
: this determines in how many points between themin
and themax
the function is sampled. If this isdouble.NaN
(the default), the resolution is determined automatically based on the coordinate system. Set this to a small value to make the plot smoother.bool vertical
: if this istrue
(the default), the argument of the function is on theX
axis, and the value of the function is on theY
axis. If this isfalse
, the argument of the function is on theY
axis and the value of the function is on theX
axis.bool smooth
: if this istrue
, the sampled values for the function are connected by a spline that passes through all of them. If this isfalse
(the default), straight line segments are used instead.PlotElementPresentationAttributes linePresentationAttributes
: this determines the appearance of the line connecting the sampled values for the function.PlotElementPresentationAttributes pointPresentationAttributes
: this determines the appearance of the symbols drawn at the sampled values for the function.double pointSize
: this determines the size of the symbols drawn at the sampled values for the function. The default for this is0
, which means that no symbols are drawn at these points.IDataPointElement dataPointElement
: this parameter determines the appearance of the symbols drawn at the sampled values for the function.
For the overload taking a collection of functions, the parameters linePresentationAttributes
, pointPresentationAttributes
, pointSize
and dataPointElements
are defined as IReadOnlyList<>
s instead of individual elements.
The following example shows the effect of some of these parameters when plotting multiple functions: