Create new plot (asynchronous constructor)

(newplot canvas)
anewplot canvas [instructions]
(anewplot canvas [instructions] expr1 expr2 ...)
anewplot canvas function
(anewplot canvas function expr1 expr2 ...)

(newp canvas)
anewp canvas [instructions]
(anewp canvas [instructions] expr1 expr2 ...)
anewp canvas function
(anewp canvas function expr1 expr2 ...)

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 constructor is executed in parallel to subsequent instructions of the turtle/object (or another plot) which called anewplot instruction. The constructor's arguments can be passed as optional expressions.

Example 1:

"p := anewp "Plot [
  "data := genarray 120 [
    let "x 3 * :index - 180
    array :x 100 * sin :x
  ]
]

Output: plot y=100*sin(x)

Example 2:

to plot_sin :a :f
  "data := genarray 120 [
    let "x (3 * :index - 180)
    array :x :a * sin :f * :x
  ]
  :style,"mode := "line
  setr 0
  (print :a :f)
end

"p := genarray 21 [(anewp "Wykres $plot_sin 7*:index :index/10)]

Output:

Note: the different behavior if anewp is replaced with newp.

7 0.1
14 0.2
21 0.3
28 0.4
35 0.5
....

See also:

Turtle - plot - object
newp, newplot - create plot (synchronous constructor)

Table of Content