I would like to plot multiple lines with MATLAB and do it so, that markers would be different in every line. I know that with colours this would be achieved with ColorSet = hsv(12);
. Is there some as simple as this method for markers?
Plot Multiple Lines By default, MATLAB clears the figure before each plotting command. Use the figure command to open a new figure window. You can plot multiple lines using the hold on command. Until you use hold off or close the window, all plots appear in the current figure window.
If you specify a marker symbol and do not specify a line style, then plot displays only the markers with no line connecting them. Alternatively, you can add markers to a line by setting the Marker property as a name-value pair. For example, plot(x,y,'Marker','o') plots a line with circle markers.
Create a plot with a red dashed line and circular markers by specifying the linespec argument as '--or' . For this combination, '--' corresponds to a dashed line, 'o' corresponds to circular markers, and 'r' corresponds to red. You do not need to specify all three aspects of the line.
Well, I am not aware of a built-in functionality of MATLAB to do so, but I do the following. I create my own cell:
markers = {'+','o','*','.','x','s','d','^','v','>','<','p','h'}
and then access it this way:
markers{mod(i,numel(markers))+1}
I also created a function, getMarker
, that does that and that I added to the path of MATLAB so that I can access it in all my scripts.
x = linspace(0, 2*pi);
y = cos(bsxfun(@plus, x(1:15:end), x'));
figure
m = {'+','o','*','.','x','s','d','^','v','>','<','p','h'};
set(gca(), 'LineStyleOrder',m, 'ColorOrder',[0 0 0], 'NextPlot','replacechildren')
plot(x, y)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With