MathGroup Archive 2006

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

Search the Archive

Re: Getting Color *names* as strings?

  • To: mathgroup at
  • Subject: [mg67493] Re: Getting Color *names* as strings?
  • From: bghiggins at
  • Date: Wed, 28 Jun 2006 03:52:01 -0400 (EDT)
  • References: <e7qmpk$6ne$>
  • Sender: owner-wri-mathgroup at

Here is one way,

<< Graphics`Colors`

Now generate a list of all the colors (as a string) and their RGBColor:

allColrs = Map[{#, ToColor[ToExpression[#], RGBColor]} &, AllColors];



{"Apricot", RGBColor[1., 0.340007, 0.129994]}

Now use Cases to get the corresponding string value from the RGBColor
value in the list greens

  greens={CinnabarGreen, ChromeOxideGreen, CobaltGreen};

colrs=Flatten[Map[Cases[allColrs, {x_String,#}->x]&,greens]];

 Do[ Plot[ Sin[x], {x, 0, 2p}, PlotStyle -> greens[[k]],
                    PlotLabel -> colrs[[k]] ] ,
         {k, 1, Length[greens]} ];

Hope this helps,


AES wrote:
> Trying out different named Colors in a plot by using
>    greens={CinnabarGreen, ChromeOxideGreen, CobaltGreen, etc};
>    Do[ Plot[ func, range, PlotStyle -> greens[[k]],
>                     PlotLabel -> ToString[greens[[k]]] ] ,
>          {k, 1, Length[greens]} ];
> Works fine -- except the PlotLabel comes out as "RGB[num, num, num]" --
> and using SymbolName[greens[[1]]] or even SymbolName[CinnabarGreen] does
> _not_ give the string "CinnabarGreen".
> How can I get the *name* of each color as a string to put in PlotLabel
> or in a Text label?
> (Trivial problem, I agree, but just frustrating enough to be interesting)

  • Prev by Date: Re: solving an equation with sums
  • Next by Date: Re: Solving an equation
  • Previous by thread: Re: Getting Color *names* as strings?
  • Next by thread: Re: Getting Color *names* as strings?