Plot/Colors

From J Wiki
Jump to navigation Jump to search
Plot | Verbs | Class Commands Data Options Outputs Types | Colors Fonts Keys Text YAxes | Function Multi Shape

Several color schemes are used in Plot.

Before any drawing is made, the backcolor is applied to the plot box. The axes, frame, ticmarks, labels and titles are then drawn in the forecolor.

Text specified with the text , textc and textr commands is drawn with the textcolor.

Data is colored in two ways, depending on plot type:

  • where each data item is plotted in a single color (e.g. line plots), the items are drawn with the itemcolor
  • where a data item is banded and requires several colors to plot, (e.g. density plots), it is drawn with the bandcolor.

The edges of filled-in shapes are drawn with the edgecolor (usually black).

Backcolor, forecolor, textcolor and edgecolor are single colors.

Itemcolor and bandcolor are lists of colors. Itemcolor typically contains quite distinctive colors to distinguish the different data items. Bandcolor is typically a graduated scale of colors, for example to indicate height. Typical lists of colors are defined in ~system\classes\plot\plotdefs.ijs (J-602) or in ~\addons\graphics\plot\plotdefs.ijs (J-801).

The term color can also be used as an abbreviation to specify the itemcolor or the bandcolor depending on plot type. This is convenient for simple plots where only one plot type is being drawn.

The keycolor is used for keys. By default this is the colors used in the plot, however, in some cases you need to specify this separately.

For example:

pd 'itemcolor blue,red,green'     NB. list of colors for items
pd 'bandcolor bgclr'              NB. list of colors in color band
pd 'color blue,red'               NB. item or band colors (depends on plot type)

The jzplot.ijs script defines several color schemes, for example:

  • STDCLR is the color scheme used by default
  • RBCLR , RGCLR , RGBCLR and BGCLR are color schemes that are appropriate for 3D surface plots. Here RBCLR is a scale of 64 steps from red to blue, etc.
  • GRAYSCALE is gray shades in 100 steps from black to white.

The colors in the standard color scheme are given in [1]

Custom color schemes can be defined. The name of the noun containing the list of colors must be all uppercase. So for example a color scheme of 3 colors (red, green and blue) could be defined as:

MYCLR_z_=: 255 0 0 , 0 255 0 ,: 0 0 255

And specified during plotting like this:

pd 'itemcolor MYCLR'