colororder — Set or query the plotting color order in MATLAB and RunMat.

colororder controls the implicit series colors used by line-style plotting commands. RunMat supports querying the current color order, setting figure-wide or axes-specific palettes, RGB triplet matrices, string and cell string color specifications, hex colors, and common MATLAB palette names.

Syntax

C = colororder()
C = colororder(target)
colororder(colors)
colororder(palettename)
colororder(target, colors)

Inputs

NameTypeRequiredDefaultDescription
targetAnyYesTarget figure or axes handle.
colorsAnyYesm-by-3 RGB matrix, color name array, color cellstr, palette name, or default.

Returns

NameTypeDescription
CNumericArrayCurrent color order as an m-by-3 RGB triplet matrix.

Errors

IdentifierWhenMessage
RunMat:colororder:InvalidArgumentTarget handle, color array, palette name, or color specification is invalid.colororder: invalid argument
RunMat:colororder:InternalInternal plotting state update fails.colororder: internal operation failed

How colororder works

  • colororder() returns the current figure color order as an m-by-3 RGB triplet matrix.
  • colororder(colors) sets the color order for the current figure and applies it to existing axes.
  • colororder(ax, colors) sets the color order for the specified axes without changing the current axes.
  • colororder(fig, colors) sets the color order for every axes in the specified figure.
  • Numeric color arrays must be m-by-3 RGB triplet matrices with finite values in [0, 1]. A single RGB triplet vector is accepted as one color.
  • String and cell string color arrays accept MATLAB color names, short color tokens, and #RGB or #RRGGBB hex strings.
  • Palette names include default, gem, gem12, glow, glow12, sail, reef, meadow, dye, and earth.
  • Changing the color order recolors existing line/scatter/bar-family series cyclically and controls future implicit plot colors.

Examples

Set a custom RGB color order

x = 0:0.1:1;
plot(x, x, x, x.^2, x, x.^3);
colororder([1 0 0; 0 0.5 0; 0 0 1]);

Expected output:

% Existing and future implicit series use red, green, and blue cyclically.

Use color names and hex strings

colororder({'red', '#00AAFF', 'black'});
plot(1:5, rand(5,3));

Set an axes-specific color order

ax1 = subplot(1,2,1);
plot(rand(5,3));
ax2 = subplot(1,2,2);
plot(rand(5,3));
colororder(ax2, 'gem');

Using colororder with coding agents

Open a RunMat example with live inputs, then ask the agent to explain how colororder changes the result.

Run a small colororder example, explain the result, then change one input and compare the output.

FAQ

How is colororder different from colormap?

colororder controls the discrete sequence of implicit colors for plot series such as lines and scatter groups. colormap controls continuous color mapping for image, surface, heatmap, and contour data.

Does colororder gather gpuArray plot data?

No. The builtin only updates axes and figure style metadata plus existing plot object colors. It does not read or materialize plotted numeric data.

Does setting colororder change the current axes?

No. Targeted forms such as colororder(ax, colors) update that axes without selecting it as the current axes.

More plotting resources

Open-source implementation

Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how colororder is executed, line by line, in Rust.

About RunMat

RunMat is an open-source runtime that executes MATLAB-syntax code blazing on any GPU. It is licensed under the Apache 2.0 license.

  • RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed. Simulations that took hours now take minutes.
  • Start running code in seconds. RunMat runs in the browser, on the desktop, or from the CLI. No license server, no IT ticket.

Getting started · Benchmarks · Pricing

Download RunMat

Download RunMat for full performance, or use RunMat in your browser for zero setup.