colorcube — Return the colorcube colormap as an m-by-3 RGB array.
colorcube returns a colorcube palette as an m-by-3 numeric RGB array with values in [0, 1]. With no argument, it uses the current colormap length, or 256 when no figure colormap length is active.
Syntax
c = colorcube()
c = colorcube(m)Inputs
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
m | NumericScalar | No | current colormap length or 256 | Number of colors as a nonnegative integer. |
Returns
| Name | Type | Description |
|---|---|---|
c | NumericArray | m-by-3 RGB colormap array with values in [0, 1]. |
Errors
| Identifier | When | Message |
|---|---|---|
RunMat:colormapArray:InvalidArgument | The requested colormap length or RGB colormap array is invalid. | colormap array: invalid argument |
How colorcube works
colorcube()returns an m-by-3 RGB matrix.colorcube(m)returns exactlymrows, wheremmust be a nonnegative integer.- The result can be passed directly to
colormap.
Examples
Apply a colorcube colormap
surf(peaks(40));
colormap(colorcube(64));
colorbar;Generate a colorcube matrix
c = colorcube(32);Using colorcube with coding agents
Open a RunMat example with live inputs, then ask the agent to explain how colorcube changes the result.
Run a small colorcube example, explain the result, then change one input and compare the output.
FAQ
What size is colorcube()?⌄
It returns the active colormap length when one exists, otherwise 256 rows by 3 columns.
Related Plotting functions
2D Charts
area · bar · errorbar · heatmap · hist · histogram · loglog · pie · plot · scatter · semilogx · semilogy · stairs · stem
Other
addpoints · ancestor · animatedline · axes · barh · cla · clf · colororder · copyobj · daspect · datacursormode · dataTipTextRow · fcontour · figure · fill3 · findobj · fsurf · gobjects · groot · hgload · hgsave · hidden · histogram2 · hold · line · linkaxes · openfig · opengl · pan · parula · patch · plotmatrix · plotyy · polarhistogram · polarplot · polarscatter · print · quiver3 · ribbon · saveas · savefig · sphere · stackedplot · subtitle · suptitle · textscatter · textscatter3 · triplot · waitbar · wordcloud · xline · xscale · xtickangle · xtickformat · xticklabels · xticks · yline · yscale · ytickangle · ytickformat · yticklabels · yticks · zoom
Open-source implementation
Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how colorcube is executed, line by line, in Rust.
- View the source for colorcube in Rust on GitHub
- Learn how the RunMat runtime works
- Found a bug? Open an issue with a minimal reproduction.
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.