MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: How to combine graphics pimitives and Plot function?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg107030] Re: How to combine graphics pimitives and Plot function?
  • From: Bill Rowe <readnews at sbcglobal.net>
  • Date: Mon, 1 Feb 2010 06:10:45 -0500 (EST)

On 1/31/10 at 7:53 AM, a.dozy.boy at gmail.com (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 Epilog. For example,

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

Plot[Sin[x], {x, -10 Pi, 10 Pi},
  Epilog -> {Red,
    Line[Transpose@{Rescale[Range[100], {1, 100}, {-10 Pi, 10 Pi}],
       points}]}]

Notice, where things intersect, the color of the intersection is
red. Anything in the Epilog list over writes existing graphics.
If you want the plot to be dominant, you should replace Epilog
with Prolog. This can be handy for showing say the fit of a
curve to data. For example

curve = m x + b /. FindFit[Sort@points, m x + b, {m, b}, x];

Plot[curve, {x, 1, 100},
  Prolog -> {GrayLevel[0.7], PointSize[.015],
    Point[Transpose@{Range@100, Sort@points}]}, Axes -> None,
  Frame -> True]



  • Prev by Date: Re: newbe question about Sting Comparison
  • Next by Date: Evaluating Problem in Generating Random Text
  • Previous by thread: Re: How to combine graphics pimitives and Plot function?
  • Next by thread: Re: How to combine graphics pimitives and Plot function?