I want to plot multiple lines with one call to plot()
, with different line styles for each line. Here's an example:
Both
plot([1,2,3]', [4,5;6,7;8,9], {'-o', '-x'})
and
hs = plot([1,2,3]', [4,5;6,7;8,9])
set(hs, 'LineStyle', {'--'; '-'})
don't work. I've tried a whole bunch of arcane combinations with square and curly braces, but nothing seems to do the trick.
I know it's possible to loop through the columns in Y and call plot()
for each one (like in this question), but that isn't what I'm after. I would really like to avoid using a loop here if possible.
Thanks.
PS: I found this 'prettyPlot' script which says it can do something like this, but I want to know if there's any built-in way of doing this.
PPS: For anyone who wants a quick solution to this, try this:
for i = 1:length(hs)
set(hs(i), 'Marker', markers{i});
set(hs(i), 'LineStyle', linestyles{i});
end
e.g. with markers = {'+','o','*','.','x','s','d','^','v','>','<','p','h'}
plot()
isn't really practical for me. Is there a way of passing in some sort of cell-array which magically unfolds into the parameter specification above? – Dichromatism