MathGroup Archive 2010

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

Search the Archive

Re: Re: Re: How to combine graphics

  • To: mathgroup at smc.vnet.net
  • Subject: [mg107103] Re: [mg107065] Re: [mg107024] Re: [mg107011] How to combine graphics
  • From: Murray Eisenberg <murray at math.umass.edu>
  • Date: Wed, 3 Feb 2010 06:07:36 -0500 (EST)
  • Organization: Mathematics & Statistics, Univ. of Mass./Amherst
  • References: <201002020825.DAA08612@smc.vnet.net>
  • Reply-to: murray at math.umass.edu

No, after

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

the code

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

works just fine with Presentations.

Yes, when I subsequently used ComplexLine with a list of complex 
numbers, I should have consistently used pts (not points) in order to 
distinguish the original list of pairs of reals and the new list of 
complex numbers:

   pts = RandomComplex[{-1 - I, 1 + I}, 100];
   Draw2D[{Draw[Sin[x],{x,-Pi,Pi}],Red,ComplexLine[pts]},Axes->True]

On 2/2/2010 3:25 AM, Tomas Garza wrote:
> Thanks, Murray. May I point out a couple of typos in your message: in
>
>>     Draw2D[{
>>             Draw[Sin[x],{x,-Pi,Pi}],
>>             {Red,Line[points]}
>>             },
>>             Axes->True]
>
> should be {Red, ComplexLine[points]}
> and in
>
>      >  Draw2D[{Draw[Sin[x],{x,-Pi,Pi}],Red,ComplexLine[pts]},Axes->True]
>
> should be ComplexLine[points]
>
> Tomas
>
>> Date: Mon, 1 Feb 2010 06:09:40 -0500
>> From: murray at math.umass.edu
>> Subject: [mg107024] Re: [mg107011] How to combine graphics pimitives and Plot function?
>> To: mathgroup at smc.vnet.net
>>
>> 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]
>>
>> --
>> Murray Eisenberg                     murray at math.umass.edu
>> Mathematics&  Statistics Dept.
>> Lederle Graduate Research Tower      phone 413 549-1020 (H)
>> University of Massachusetts                413 545-2859 (W)
>> 710 North Pleasant Street            fax   413 545-1801
>> Amherst, MA 01003-9305
>>
>

-- 
Murray Eisenberg                     murray at math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower      phone 413 549-1020 (H)
University of Massachusetts                413 545-2859 (W)
710 North Pleasant Street            fax   413 545-1801
Amherst, MA 01003-9305


  • Prev by Date: Re: Export[..., ImageResolution, ... ImageSize]
  • Next by Date: Re: Re: What does & mean?
  • Previous by thread: Re: Re: How to combine graphics pimitives and
  • Next by thread: Re: Re: How to combine graphics pimitives and