User Tools

Site Tools




As part of a toolbox with a GUI that supports statistical map overlay, I wanted to have a nice interface to select (pick) colors. Most programs (e.g. Photoshop) have a comparable option.

Function reference ('help colorpicker')

  colorpicker  - pick a color from the RGB/HSV color space
  FORMAT:       color = colorpicker([icolor [, icnames]]);
  Input fields:
        icolor      initial color or colors (default: [0, 0, 0]);
        icnames     color name(s) (labels)

  Output fields:

        color       Cx3 RGB color (values in the [0...255] range)

GUI layout and functionality

The general layout is always the same and looks like this:

colorpicker with a single color

Each of the five areas showing a color-gradient is click-sensitive, which means that by clicking at a given position, the color will change to the color below the mouse cursor.

Additionally, colors can be coded either in the HSV or RGB color space (with a scaling of [0 .. 255] for each value).

The buttons on the lower right side will

  • reset the color to the values given at call time (Reset)
  • close the dialog without altering the values given at call time (Cancel)
  • close the dialog and return the colors as they were displayed at the time (Accept)

If multiple colors are to be shown (e.g. a palette), names can be given and instead of one uni-colored patch in the top right corner, a grid of colors is presented, which itself is click-sensitive to switch between colors:

colorpicker with a palette of colors (colormap 'hot')


This function requires the xfigure class to be working properly!

colorpicker.txt · Last modified: 2010/06/22 05:44 by jochen