Mathematica 9 is now available
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: [mg111191] Re: A Question About Directive
  • From: Mark McClure <mcmcclur at unca.edu>
  • Date: Fri, 23 Jul 2010 07:11:16 -0400 (EDT)
  • References: <i293pl$m64$1@smc.vnet.net>

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: Accepting string input with quotes in Manipulate
  • Next by Date: Re: Big Memory Needed Again
  • Previous by thread: Re: A Question About Directive
  • Next by thread: Re: A Question About Directive