Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2010

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

Search the Archive

Re: A Question About Directive

  • To: mathgroup at smc.vnet.net
  • Subject: [mg111107] Re: A Question About Directive
  • From: Murray Eisenberg <murray at math.umass.edu>
  • Date: Tue, 20 Jul 2010 03:45:19 -0400 (EDT)

In some situations, using Directive[opt1,opt2] instead of {opt1,opt2} 
can make code easier to read by avoiding nested parentheses.

Compare, for example:

   Plot[{Sin[x],Cos[x]},{x,0,Pi},PlotStyle->
      {Directive[Thick,Red],Directive[Thick,Dashed,Blue]}]

   Plot[{Sin[x], Cos[x]}, {x, 0, Pi},
       PlotStyle -> {{Thick, Red}, {Thick, Dashed, Blue}}]

On 7/19/2010 2:10 AM, Kevin J. McCann wrote:
> I have noticed the use of Directive in some of the graphics examples
> from Bob Hanlon, David Park, and others. I am curious about this
> command, since it does not appear to do much that is new. For example,
> here is an example from the Help on Directive:
>
> Graphics[{Directive[Red, Thick], Circle[],
>     Directive[Blue, Opacity[0.5]], Rectangle[{0, -1}, {2, 1}]}]
>
> However, if I change to this, I get the same thing:
>
> Graphics[{Red, Thick, Circle[], Blue, Opacity[0.5],
>     Rectangle[{0, -1}, {2, 1}]}]
>
> So, what is the benefit of Directive?
>
> Thanks,
>
> Kevin
>

-- 
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: Avoid the use of certain functions
  • Next by Date: Re: Kolmogorov-Smirnov 2-sample test
  • Previous by thread: A Question About Directive
  • Next by thread: Re: A Question About Directive