From: Kevin J. McCann on
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

From: Murray Eisenberg on
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(a)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

From: Helen Read on
On 7/20/2010 3:45 AM, Murray Eisenberg wrote:
> 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}}]

I have run into examples where I simply can't get things to work the way
I want without Directive, but of course I can't come up with one this
morning....

--
Helen Read
University of Vermont

From: Kevin J. McCann on
Thanks Murray. I understand, but that seems like very little improvement
at the cost of a new function. Surely, there must be more. BTW, I think
I like the old way better - fewer keystrokes, and I am old fashioned ;)

Kevin

Murray Eisenberg wrote:
> 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
>>
>

From: Kevin J. McCann on
Thanks Murray. I understand, but that seems like very little improvement
at the cost of a new function. Surely, there must be more. BTW, I think
I like the old way better - fewer keystrokes, and I am old fashioned ;)

Kevin

Murray Eisenberg wrote:
> 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
>>
>