myplot: conveniently plotting multiple curves in 2D
% A wrapper of "plot" for convienient 2D-plot of multiple curves.
% Multiple calls of myplot (with 'hold' switched on) generate curves
% automatically cycling through a sequence of styles and colors,
% and automatically numbered in the legend.
% By Chi-Hang Lam, Jan 2019
%
% Usage: myplot( [<options>], [<arguments>], ... )
% <arguments> :
% arguments to be sent to the 'plot' function
% <options>:
% 'll' 'lx' 'ly' :set log-log or semi-log scales
% 'po' 'li' 'lp' :set style of this and subsequent curves to point, line, or linepoint
% 'dot' 'dash' 'dashdot' :set line style to dotted, dashed, or dashed-dotted
% 'style', <style> :set default style to <style> = 'po', 'li', or 'lp'
% 'color',<index> :set color based on <index>
% 'marker',<index> :set marker based on <index>
% 'noinc' :do not automatically advance to next color/marker for this curve
% 'group', <n> :sebsequent cuvers advance to next marker/color after every <n> curves
% 'ctitle',<ctitle> :set curve label to <ctitle> in legend
% 'noleg' :do not show curve in legend
% 'clear' :clear plot and reset curve counter
% 'graph',0 :do not plot this curve, i.e. neglect this function call
% 'jet',<ncolor> :use matlab's jet colormap with <ncolor> colors for this curve
%
% Arguments and options can be mixed in arbitrary order
% Requires: getopt.m
% e.g. x=1:10; hold on; myplot('ll', x,x); myplot(x,2*x);
% See myplotdemo.m for more examples
Cite As
Chi-Hang Lam (2025). myplot: conveniently plotting multiple curves in 2D (https://www.mathworks.com/matlabcentral/fileexchange/69946-myplot-conveniently-plotting-multiple-curves-in-2d), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform Compatibility
Windows macOS LinuxCategories
- MATLAB > Graphics > 2-D and 3-D Plots > Line Plots >
Tags
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.
Version | Published | Release Notes | |
---|---|---|---|
1.0.0 |