Custom line style for plot function

Use your custom line style
457 Downloads
Updated 19 Aug 2021

View License

Use your custom line style with function named plot_dash
You can design your line pattern and its length by the parameter spec_ and num_
For instance,
  1. Matlab default dashed line ∽ spec_ = [1, 0.5], n_ = 27.1
  2. Matlab default solid line = spec_ = [1, 0.0], n_ = any number but 1 recommanded
  3. Matlab default dotted line ∽ You can do it with this code, but just use matlab default option to save your memory (50 points are created per one pattern)
  4. Long dashed line ∽ spec_ = [1, 0.5], n_ = 10
  5. Dashed dot line ∽ spec_ = [1, 0.1, 0.1, 0.1], n_ = 26
  6. ...
This line style is not shown for the Matlab's default legend function.
So, I provide not-sophisticated additional functions
See example codes and you'll get it.
P.S.
  1. Odd components of spec_ is length of solid part of the pattern
  2. Even components of spec_ is length of empty part of the pattern
  3. There's no limit for the spec_'s dimension
  4. However, dimension of the spec_ should be even number
  5. n_ is the number of patterns that can be fitted in the line x = xlim, y = [0, 0]
  6. Don't worry. It works based on the curve length, not the x array

Cite As

Seongmun Jung (2024). Custom line style for plot function (https://www.mathworks.com/matlabcentral/fileexchange/97512-custom-line-style-for-plot-function), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2021a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.0.3

1. Changed functions' names
2. plotLegendBoundary, plotLegendLine, and plotLegendSymbol are added

1.0.2

TYPO

1.0.1

Correcting typo

1.0.0