More Line Styles in Matlab - Without Markers?

Is there some way to plot more than 4 line styles in Matlab (as it is stated here ), I mean line styles without markers?

I 've tried but there is some problem, it does not display line correct in the legend.

Next solution for me is gnuplot, but I have whole calculation in Matlab. Is there any other advice, what other to use or what to do with Matlab to make more than 4 line styles? Will there be more line styles in next Matlab version?

2

1 Answer

There are only 4 line styles, and realistically that's probably a reasonable limit in terms of legibility. But there are lots of marker styles, why not make your own "lines" by plotting close together markers?

x = 1:0.01:2;
a = sin(x);
b = sin(x) - sort(rand(size(x))/4);
c = sin(x) + sort(rand(size(x))/10);

figure;
hold on
plot( x, a, 'linestyle', 'none', 'marker', 's' );
plot( x, b, 'linestyle', '-', 'marker', 'o' );
plot( x, c, 'linestyle', '-', 'marker', '*', 'linewidth', 1, 'markersize', 5);

You might need to do some interpolation to upsample your data to create the line illusion from close-together markers, interp1 is a simple way to do this.

Although I would echo Cris's comment, your plot will quickly become cluttered, consider using subplots, colours, or other devices to illustrate different series and avoid chart clutter.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Robert Thorne

Robert Thorne

Automotive & Future Transportation Editor

Robert Thorne covers electric vehicle innovations, autonomous driving systems, global mobility trends, and automotive engineering developments.

Share this article
Twitter Facebook Pinterest