Re: How to combine graphics pimitives and Plot function?

• To: mathgroup at smc.vnet.net
• Subject: [mg107025] Re: How to combine graphics pimitives and Plot function?
• From: Helen Read <hpr at together.net>
• Date: Mon, 1 Feb 2010 06:09:51 -0500 (EST)
• References: <hk3ug1\$dr1\$1@smc.vnet.net>
• Reply-to: HPR <read at math.uvm.edu>

```On 1/31/2010 7:53 AM, a boy wrote:
> points = RandomReal[{-1, 1}, {100, 2}]
> Graphics[{Red, Line[points], Plot[Sin[x], {x, -10 Pi, 10 Pi}]},
>   Axes ->  True]
>
> The code doesn't work. how to draw them together? ImageCompose ?

Use Show to combine Plots and Graphics objects, like this.

points = RandomReal[{-1, 1}, {100, 2}];

plot1 = Plot[Sin[x], {x, -Pi, Pi}]

plot2= Graphics[{Red, Line[points]}]

Show[{plot1, plot2}]

Show will often benefit by setting an explicit PlotRange or use
PlotRange->Automatic

You can also add Graphics objects to a Plot with Epilog, like this.

Plot[Sin[x], {x, -Pi, Pi}, Epilog -> {Red, Line[points]}]

--
Helen Read
University of Vermont

```

• Prev by Date: Re: How to combine graphics pimitives and Plot function?
• Next by Date: What does & mean?
• Previous by thread: Re: How to combine graphics pimitives and Plot function?
• Next by thread: Re: How to combine graphics pimitives and Plot function?