Create new plot (synchronous constructor)
(newplot canvas)
newoplot canvas [instructions]
(newplot canvas [instructions] expression1 expression2 ...)
newplot canvas function
(newplot canvas function expression1 expression2 ...)
(newp canvas)
newp canvas [instructions]
(newp canvas [instructions] expression1 expression2 ...)
newp canvas function
(newp canvas function expression1 expression2 ...)
Creates new plot in the graphics window named canvas. A list of instructions or a function passed as an argument
is used as constructor of the new plot. The turtle/object (or another plot) which called the newplot
instruction is waiting for the new plot's constructor completion before it continues its own code. The
constructor's arguments can be passed as optional expressions.
Example 1:
"p := newp "Plot [
"data := genarray 120 [
let "x 3 * :index - 180
array :x 100 * sin :x
]
]
Output: plot y=100*sin(x)
Example 2:
to pmodel
to fn :k
let "j 1
for [i -180 180 3] [
:data,:j,1 := 100 * cos :A * :i + :k
:data,:j,2 := 100 * sin :B * :i + :k
"j += 1
]
end
"A := 1 "B := 1
"data := (newarray 121 {0 0})
"t := timer [fn :iter refresh] 30
"u := timer ["A := (random 1 6) "B := (random 1 6)] 2500
setr 0.5
end
"p := newp "Sin $pmodel
Output:
Animated Lissajous curves.
Example 3:
to phisto
to add_data :d
"v := se :v :d
"data := (histogram :v 50 (-3) 3 1)
refresh
end
to size op count :v end
setr 0
let "v []
:style,"xerr := 3
:style,"yerr := 4
end
"p := newp "Histogram $phisto
print :p
let "cfg :histogram_canvas_cfg
:cfg,"min_x := -4
:cfg,"max_x := 4
:cfg,"min_y := -0.1
:cfg,"max_y := 0.8
"t := timer [(add_data arraytolist (rnorm 0 1 10)) @ :p] 30
"u := timer [print size @ :p] 2000
Output:
See also description of histogram
instruction.
phisto1
10
670
1330
1990
2660
3320
See also:
Turtle - plot - object
anewp, anewplot - create plot (asynchronous constructor)
Table of content