From: Alexei Boulbitch on
Try this:
points = RandomReal[{-1, 1}, {10, 2}];
gr = Graphics[{Red, Line[points]}, Axes -> True];
pl = Plot[Sin[x], {x, - Pi, Pi}];
Show[{gr, pl}]




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 ?



--
Alexei Boulbitch, Dr., habil.
Senior Scientist

IEE S.A.
ZAE Weiergewan
11, rue Edmond Reuter
L-5326 Contern
Luxembourg

Phone: +352 2454 2566
Fax: +352 2454 3566

Website: www.iee.lu

This e-mail may contain trade secrets or privileged, undisclosed or otherwise confidential information. If you are not the intended recipient and have received this e-mail in error, you are hereby notified that any review, copying or distribution of it is strictly prohibited. Please inform us immediately and destroy the original transmittal from your system. Thank you for your co-operation.



From: Fred Klingener on
On Jan 31, 7:53 am, a boy <a.dozy....(a)gmail.com> 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 ?

Others have given you the most direct approaches, but if you have
special ambitions (or if the inscrutable rules Mathematica uses to
compose such things is driving you flat crazy) and you want to get
close to the bone, start by looking at (ps=Plot[Sin[x],{x,-Pi, Pi}])//
FullForm, say.

You'll see that the bare list of the geometric primitives for the
curve is available as ps[[1, 1, 3, 2]], so you can compose a Graphics
with any structure you want. Like a fanciful

Graphics[{
{Red, Line[points]}
, {Blue
, Thick
, Rotate[ps[[1, 1, 3, 2]], Pi/6.]}
}
, Axes -> True
]

Hth,
Fred Klingener

From: David Park on
To elaborate some more: There are basically two kinds of graphics options,
those that affect how some object is drawn (such as PlotPoints,
MaxRecursion, or Mesh) and those that affect the overall appearance of the
graphic (such as Frame, FrameTicks, AspectRatio, ImageSize) but do not
affect the graphics primitives that represent the objects. For casual users
using the Show statement these distinctions become somewhat of a blur and it
is not clear where the various options are coming from, or where they should
be placed. Nor do they find it easy to combine algorithm generated curves or
surfaces with graphics primitives.

Many of the experts on MathGroup know how to handle the Show statement, how
to fix up options, and how to jump graphics levels. But this is a
significant barrier to most casual users. It is enough of a barrier that
many of them don't even try custom graphics.

Primitives like Draw (for Plot) and ContourDraw (for ContourPlot) have many
fewer options than Plot and ContourPlot.

In the following you wouldn't put Frame in ContourDraw. It would have no
effect on the resulting primitives, and if you put it in the statement it
would show up as not being a proper option. The curve would be drawn as Red.

Draw2D[
{Red,
ContourDraw[y == Sin[x], {x, 0, 2 \[Pi]}, {y, -1, 1}]},
Frame -> True]

But there are caveats. The following ContourDraw statement would not pick up
the Red color because contour colors are embedded more deeply in the
primitives and specified by a ContourStyle option.

Draw2D[
{Red,
ContourDraw[Sin[x y], {x, 0, 2 \[Pi]}, {y, 0, 2 \[Pi]},
Contours -> 4,
ContourShading -> None]},
Frame -> True,
ImageSize -> 250]

Here Contours and ContourShading and ContourStyle (if we used it) would go
in the ContourDraw statement because they affect what elements are drawn and
how. But Frame and ImageSize would not go into ContourDraw because they have
no effect there, nor would one logically expect them to have an effect.

Then there are a couple of options, such as PlotRange that might appear in
both places. In ContourDraw, for example, Mathematica might eliminate
certain portions of the curves as being outliers or 'uninteresting'. One
could control this using a 'z' PlotRange in the ContourDraw statement, and
then one might use an 'x' and 'y' PlotRange for the overall Draw2D
statement. So we might have a number of PlotRange options controlling
separate portions of the graphic.

Once one understands how these things work it is much more logical and easy
to build up custom graphics (and custom dynamics too). As I like to say, you
just draw one thing after another and you put the options where they
logically do something.

Another nice feature in Presentations is the OptionFinder that was
contributed by Thomas M=FCnch and Syd Geraghty. It provides a quick method to
find the options for various statements, and all the drawing statements,
clicking the options into the statement, or quickly accessing Help for them.

Another nice feature of always working on the graphics primitives level is
that it is very easy to apply various transformations to individual parts.
One might generate some basic object and then transform it to multiple
objects, while leaving other objects fixed.


David Park
djmpark(a)comcast.net
http://home.comcast.net/~djmpark/


From: DrMajorBob [mailto:btreat1(a)austin.rr.com]


Presentations gives the same graph with even LESS complexity, too:

Draw2D[{Draw[Sin[x], {x, -Pi, Pi}], Red, Line[points]}, Axes -> True]

(No need to put Red and Line in a List together.)

I think David deliberately made Draw2D's argument a List in order to
emphasize this point, or something like it. Directives and graphics are
sequentially applied, and Draw2D options apply to the overall drawing.

This works just as we'd expect it to, as well:

Draw2D[{Blue, Draw[Sin[x], {x, -Pi, Pi}], Red, Line[points],
Draw[Cos[x], {x, -Pi, Pi}]}, Axes -> True]

and so does this:

Draw2D[{Blue, Draw[Sin[x], {x, -Pi, Pi}], Red, Line[points],
Draw[Cos[x], {x, -Pi, Pi}]}, Axes -> True, AxesStyle -> Purple,
Background -> LightPink]

Bobby