Plot Color Bars
Description
Options
Examples
Color bars can be added automatically with the colorbar option to many types of plots, most notably, contour plots and density plots. When such plots are combined with plots:-display color bars may be removed since it is not possible for a single plot to have more than one color bar at a time.
The options listed below may be provided to the colorbar option in plot commands that support it. These options can be included in a list (colorbar=list_of_options) and are generally available to all commands that support color bars. The help page for a particular command may provide more detail about the colorbar options it accepts.
barcaption=c
The caption for the color bar. The value c can be a string or a typesetting expression. For information on how to specify c, see plot/typesetting. The default is no caption.
barlabels=l
The labels for color bar. The value l should be a list of real number values.
captionfont=l
This option defines the font for the caption barcaption. The value l must be a list of the form [family, style, size] where valid values are the same as font described in plot/options.
discrete
This option given as discrete or discrete=true causes the color bar to be rendered in discrete stripes instead of a continuous gradient. This is not supported by all plot commands, in particular, not by densityplot.
labelcount=n
This option overrides the default algorithm to choose well-spaced labels for the colorbar and instead forces n equally spaced labels from the actual minimum to the actual maximum values in the plot.
labelfont=l
This option defines the font for the label values. The value l must be a list of the form [family, style, size] where valid values are the same as font described in plot/options.
labelformat=s
The printf formatting string used to render the bar labels or the name typeset. In the former case labels are passed to evalf and then rendered with sprintf. In the latter case, they are directly wrapped in typeset per plot/typesetting. The default value of s is "%0.3g" which renders three floating-point digits.
plots:-contourplot⁡sin⁡x⁢y,x=−1..1,y=−1..1,colorbar=discrete
plots:-densityplot⁡sin⁡x⁢y,x=−3..3,y=−3..3,colorbar=barcaption=typeset⁡z=sin⁡x⁢y,captionfont=HELVETICA
A≔Matrix⁡21,21,i,j↦evalf⁡sin⁡i−11⋅j−11100,datatype=float8:
plots:-matrixplot⁡A,dimension=2,gap=0.1,colorbar=labelcount=5,labelfont=Roman,Bold,size=600,400
plots:-surfdata⁡A,colorscheme=Viridis,dimension=2,colorbar=barlabels=−0.75,−0.5,−0.25,0,0.25,0.5,0.75
Color bar plot objects can be created with the plottools:-colorbar and added to plots with plots:-display
cb≔plottools:-colorbar⁡−1..1,Viridis,discrete,barlabels=−0.8,−0.4,0,0.4,0.8
cb≔COLBAR⁡PLOT⁡...,PLOT⁡...
plots:-display⁡plot⁡x2,cb
See Also
plot/options
plot/typesetting
plots[contourplot]
plottools:-colorbar
Download Help Document