Re: A Question About Directive

• To: mathgroup at smc.vnet.net
• Subject: [mg111237] Re: A Question About Directive
• From: "Kevin J. McCann" <Kevin.McCann at umbc.edu>
• Date: Sat, 24 Jul 2010 05:09:08 -0400 (EDT)
• References: <i293pl\$m64\$1@smc.vnet.net> <i2btc7\$bcc\$1@smc.vnet.net>

```Mark,

I'll agree that your example with the use of the Inner product is a
clever way to do that, but isn't this way more readable?

Graphics[{
Red,PointSize[Large],Point[{0,0}],
Blue,PointSize[Medium],Point[{1,0}]
},
AspectRatio->1/10]

Seems like a lot of overhead with the use of Inner and Directive.

But if you prefer more keystrokes and the use of two additional
functions (Inner, Directive)

Graphics[
Inner[List, {
Directive[Red, PointSize[Large]],
Directive[Blue, PointSize[Medium]]
},
{Point[{0, 0}], Point[{1, 0}]},
List],
AspectRatio -> 1/10]

then have at it ;)

Kevin

Mark McClure wrote:
> On Thu, Jul 22, 2010 at 10:01 AM, Kevin J. McCann <Kevin.McCann at umbc.edu> w=
> rote:
>> A couple have responded with something like Mark's example below. Is this
>> really worth a new function and more keystrokes over:
>>
>> Plot[{Cos[x], Sin[x]}, {x, 0, 2 Pi},
>>  PlotStyle -> {{Thick, Red}}]
>
>
> I still rather like Directive, primarily due to it's clarity.  It
> certainly follows Wolfram's TypeExactlyWhatYouMean philosophy.
>
>>From a programmatic perspective, it can be convenient to encase
> directives in a head other than List.  It makes it easier to use Cases
> or DeleteCases to scan for directives, for example.
>
> Here's an example where we use Inner to combine some graphics
> primitives and graphics directives.  The fact that the head Directive
> is different from the head List is essential.  I don't think you can
> change the Directive head to either a List or nested Lists.
>
> Graphics[
>  Inner[List, {
>    Directive[Red, PointSize[Large]],
>    Directive[Blue, PointSize[Medium]]
>    },
>   {Point[{0, 0}], Point[{1, 0}]},
>   List],
>  AspectRatio -> 1/10]
>
> Of course, if you prefer Lists when appropriate, then have at it! :)
>
> Mark
>

```

• Prev by Date: Re: Kolmogorov-Smirnov 2-sample test
• Next by Date: Strange use of time...
• Previous by thread: Re: A Question About Directive
• Next by thread: Re: A Question About Directive