Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When manipulating colors, the output is shown as a textual expression like Hue[1/5], RGBColor[2/3, 1, 1/3], GrayLevel[3/5]. It can be hard to visualize what color these represent.

How can you quickly display the color itself on screen?

share|improve this question

If you just want to know what a particular color looks like and don't have M9 you can set it up with Graphics in many ways. Here is one. I've added the Listable attribute so you can see many colors at once.

SetAttributes[swatch, Listable];
swatch[col_] := Graphics[{col, Disk[]}, ImageSize -> 50]

swatch[{Hue[1/5], RGBColor[2/3, 1, 1/3], GrayLevel[3/5]}]

enter image description here

share|improve this answer

Evaluate (Shift+Enter) your code for color. In Mathematica 9 the suggestion bar will appear under the output with suggestion "swatch". Just click it and you'll get a square with that color.

enter image description here

share|improve this answer

A simple way is to use a ColorSetter.

Where color is the color you want to display, run

DynamicSetting@ColorSetter@color

You can also copy the result and use it as input in a notebook.

Illustration:

Illustration

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.