## `plot::copy` -- create a copy of a graphical primitive

#### Introduction

`plot::copy``(o)` returns a copy of the graphical object `o`.

#### Call(s)

`plot::copy(o)`

#### Parameters

`o` | - | graphical object, i.e., an object of type `"graphprim"`

#### Returns

an object of the same domain type as `o`.

#### Related Functions

`plot::modify`

#### Details

- If a plot option of `o` is changed via the slot operator `::`, e.g., the color of `o` by calling `o::Color:= rgbvalue`, then the object `o` (and possibly the objects of that `o` consists) is changed due to the reference effect of domains (see Example 2). With `plot::copy` you can explicitly create a copy of `o` first, before changing plot options of this copy.

#### Example 1

We create an object representing a two-dimensional function plot:

    >> f:= plot::Function2d(sin(x), x = 0..2*PI):
       plot(f)

If we want to add another graph to the same graphical scene, built of `f` by changing its term to the cosine function and its color to blue, we must first create a copy of `f` and then change the term attribute `term` and the options `Color` and `Title` as desired:

    >> g:= plot::copy(f): g::term:= cos(x):
       g::Title := "cos(x)": g::Color:= RGB::Blue:
       plot(f, g)

#### Example 2

This example illustrate the reference effect for graphical objects. Let us create a scene consisting of three graphical objects:

    >> s:= plot::Scene(
         plot::Function2d(1/x, x = 1..50),
         plot::Pointlist([n, sin(n)/n] $ n = 1..50, Color = RGB::Blue),
         plot::Function2d(-1/x, x = 1..50)
       ):
       plot(s)

If we want to increase the size of the points of the graph of the sequence n -> sin(n)/n, we may extract the corresponding graphical object of that scene:

    >> p:= s[2]

                                 plot::Pointlist()

and set the corresponding plot option `PointWidth` to the value 50:

    >> p::PointWidth:= 50: plot(s)

Changes on the object `p` reflects changes on every object that consists of `p`, such as the graphical scene `s` in this example. This is called the "reference effect".

#### Changes

- new function

Do you have questions or comments?
Copyright © SciFace Software GmbH & Co. KG 2000