-
Notifications
You must be signed in to change notification settings - Fork 0
SVGraph_LinePlot()
Draws the curve of a function over an interval.
SVGraph_LinePlot(FunX, FunY [, Colour, Width, Resolution, Axis, Optimize])
A string representing the part of the function that defines its x coordinates. It can be any valid JavaScript that evaluates to a number, the values, from the range that's being plotted over, can be accessed through the JS variable x.
To make a "standard" function, i.e. f(x) = y, set this parameter to "x".
A string representing the part of the function that defines its y coordinates. It can be any valid JavaScript that evaluates to a number, the values, from the range that's being plotted over, can be accessed through the JS variable x.
The colour of the curve, supports HTML Color Names or Color Values. e.g. "lightgrey" or "#FF00FF".
The width of the line, as a number followed by an optional Unit e.g. 3 or "5mm".
Note: If the unit is included there should be no space between the number and the unit.
The number of equally spaced values from the range for which the function will be evaluated.
A string representing which axis/range to plot over.
To plot over the x-axis set this parameter to "x", for the y-axis use "y".
Alternatively to plot over an arbitrary range, set this parameter to a string in the format "[min,max]" where min and max are numbers.
Note: only the part of the function within the x and y-axis will be plotted.
A boolean indicating whether or not to perform extremum and edge conservation.
Note: this results in additional computation, but may look nicer.
Extremum and edge conservation is done by detecting local maxima, minima and areas in which the function is undefined or outside the x and y-axis, in these areas the resolution is increased by a factor of 10.
; Plot along the x-axis
SVGraph_Chart(width := 700, height := 365, margin := 40)
SVGraph_SetAxes(xmin := -10, xmax := 10, ymin := -1, ymax := 1)
SVGraph_LinePlot("x", "Math.sin(x)", "#0000FF", 200)
SVGraph_LinePlot("x", "Math.pow(x, 2) / 100 + 0.1", "#FF0000", 200)
SVGraph_LinePlot("x", "Math.pow(x, 3) / 100 + Math.pow(x, 2) / 100 + x / 100", "#00FF00", 200)
; Plot along the y-axis
SVGraph_Chart(width := 365, height := 700, margin := 40)
SVGraph_SetAxes(xmin := -1, xmax := 1, ymin := -10, ymax := 10)
SVGraph_LinePlot("Math.sin(x)", "x", "#0000FF", 200, "y")
SVGraph_LinePlot("Math.pow(x, 2) / 100 + 0.1", "x", "#FF0000", 200, "y")
SVGraph_LinePlot("Math.pow(x, 3) / 100 + Math.pow(x, 2) / 100 + x / 100", "x", "#00FF00", 200, "y")
; Plot over the range [-5, 5]
SVGraph_Chart(width := 700, height := 365, margin := 40)
SVGraph_SetAxes(xmin := -10, xmax := 10, ymin := -1, ymax := 1)
SVGraph_LinePlot("x", "Math.sin(x)", "#0000FF", 200, "[-5, 5]")
SVGraph_LinePlot("x", "Math.pow(x, 2) / 100 + 0.1", "#FF0000", 200, "[-5, 5]")
SVGraph_LinePlot("x", "Math.pow(x, 3) / 100 + Math.pow(x, 2) / 100 + x / 100", "#00FF00", 200, "[-5, 5]")
; Plot of the Unit Circle
SVGraph_Chart(width := 365, height := 365, margin := 40)
SVGraph_SetAxes(xmin := -1, xmax := 1, ymin := -1, ymax := 1)
SVGraph_LinePlot("Math.cos(x)", "Math.sin(x)", "#0000FF", 200, "[-5,5]", False)