Updated 28 Feb 2021
Plot a line with changing color over the course of a line.
To plot a line, run
linecm(x, y, @colormap_functionhandle);
Just like that! You now have a much better looking line. Here is an example:
set(0, 'DefaultLineLineWidth', 2); x = 0:0.1:2; y = sin(x); subplot(1, 2, 1) line(x, y, 'Color', 'b') title("Regular line") subplot(1, 2, 2) linecm(x, y, @parula); % semicolon is recommended title("linecm")
linecm looks much better!
In this file, two additional colormaps have been added:
bwr, inspired by matplotlib. You can read more about them here.
There is a similar program available called colormapline which might be less error prone.
Might be quite obvious but
linecm stands for "line colormap".
Simon Thor (2023). linecm (https://github.com/simonthor/linecm/releases/tag/v1.2.0), GitHub. Retrieved .
MATLAB Release Compatibility
Platform CompatibilityWindows macOS Linux
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!
Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
See release notes for this release on GitHub: https://github.com/simonthor/linecm/releases/tag/v1.2.0