MathGroup Archive 2010

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

Search the Archive

Re: Re: How to combine graphics pimitives and

  • To: mathgroup at smc.vnet.net
  • Subject: [mg107082] Re: [mg107024] Re: [mg107011] How to combine graphics pimitives and
  • From: DrMajorBob <btreat1 at austin.rr.com>
  • Date: Tue, 2 Feb 2010 03:28:47 -0500 (EST)
  • References: <201001311253.HAA14187@smc.vnet.net>
  • Reply-to: drmajorbob at yahoo.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

On Mon, 01 Feb 2010 05:09:40 -0600, Murray Eisenberg  
<murray at math.umass.edu> wrote:

> Trying to do this kind of thing using Mathematica's built-in paradigm
> for graphics causes trouble for many beginners.
>
> Here's one way.  (I changed the x-domain because otherwise the random
> polygon collapses to a small blur.)
>
>    points = RandomReal[{-1,1},{100,2}];
>    Show[{
>          Plot[Sin[x],{x,-Pi,Pi}],
>          Graphics[{Red,Line[points]}]
>         }]
>
> The Graphics has to apply only to the {Red,Line[points]}, as the result
> of the Plot expression is already a Graphics object.
>
> You don't need the Axes->True option, as that's the default for Plot.
> However -- and this really drives folks nuts -- if you reverse the order
> of the Graphics objects...
>
>    Show[{Graphics[{Red,Line[points]}], Plot[Sin[x], {x,-Pi,Pi}]}]
>
> ... then the axes disappear and you have to insert the Axes->True option
> within the Graphics[{Red,Line[points]}] expression:
>
>    Show[{Graphics[{Red, Line[points]}, Axes -> True],
>          Plot[Sin[x], {x, - Pi, Pi}]}]
>
> No wonder this sort of thing gives so much trouble!
>
> But a much simpler way to do the whole thing is to use the different
> paradigm that's supplied by David Park's Presentations application:
>
>    Needs["Presentations`Master`"]
>
>    points = RandomReal[{-1,1},{100,2}];
>
>    Draw2D[{
>            Draw[Sin[x],{x,-Pi,Pi}],
>            {Red,Line[points]}
>            },
>            Axes->True]
>
> Notice that the Axes->True option is for the entire Draw2D expression;
> this means you'll get axes without any further ado no matter in what
> order you list the two objects, Draw[Sin[x]....] and {Red,Line[points]}.
>
> I've deliberately pretty-printed both versions in order to emphasize the
> structure of the overall expression.
>
> In the version done with Presentations, notice that all the different
> objects to be drawn (by the Draw2D) are "at the same level", one after
> the other, so that there's no need for wrapping the {Red,Line[points]
> expression with Graphics.
>
> With Presentations, moreover, you don't have to explicitly form pairs of
> reals as coordinates of the points, but may instead form complex numbers
> directly and plot a "complex line" whose vertices are the corresponding
> complex points:
>
>    points = RandomComplex[{-1 - I, 1 + I}, 100];
>    Draw2D[{Draw[Sin[x],{x,-Pi,Pi}],Red,ComplexLine[pts]},Axes->True]
>
>
> 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]
>


-- 
DrMajorBob at yahoo.com


  • Prev by Date: Re: Re: How to combine graphics pimitives and
  • Next by Date: Re: Numerical Problem
  • Previous by thread: Re: Re: Re: How to combine graphics
  • Next by thread: Re: Re: Re: How to combine graphics