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: [mg107020] Re: [mg107011] How to combine graphics pimitives and Plot function?
  • From: "David Park" <djmpark at comcast.net>
  • Date: Mon, 1 Feb 2010 06:08:57 -0500 (EST)
  • References: <22527820.1264942798595.JavaMail.root@n11>

If you had the Presentations package your instincts would have been right
and you could write:

Needs["Presentations`Master`"]

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

Draw2D[
 {Red, Line[points],
  Black, Draw[Sin[x], {x, -10 Pi, 10 Pi}]},
 AspectRatio -> .5,
 Axes -> True]

Here Draw replaces Plot and everything is a graphics primitive. You could
also add other objects such as Text, ParametricDraw, ContourDraw or almost
any plot type.

With plain Mathematica you could instead use Graphics level jumping and
Show:

Show[
 {Graphics[{Red, Line[points]}],
  Plot[Sin[x], {x, -10 Pi, 10 Pi}]},
 AspectRatio -> .5,
 Axes -> True]

The Show statement picks up graphics options from the items in order and
this sometimes leads to confusion. In Presentations you don't need overall
graphics options in the Draw statements and there is cleaner behavior. 

Or you could use Plot with an Epilog:

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

But here you couldn't add other plot types, such as a curve drawn with
ParametricPlot or ContourPlot.


David Park
djmpark at comcast.net
http://home.comcast.net/~djmpark/  





From: a boy [mailto:a.dozy.boy at gmail.com] 

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 ?





  • Prev by Date: Re: Re: Re: position of sequence
  • Next by Date: Re: position of sequence of numbers in
  • Previous by thread: Re: How to combine graphics pimitives and Plot function?
  • Next by thread: Re: How to combine graphics pimitives and Plot function?