MATLAB: How to make the second graph look like the first

graph stylegraphingMATLABmatlab 2017

Well, obviously the second one is plotted on a single axes whereas in the first case you (or whoever wrote the script) used yyaxis to call a second yaxis. Do you even have two quantities in the second case? I mean, you only have one plot…
figure(SlopevsA)
plot(Current,Slope)
hold on

Best Answer

yyaxis automatically changes the linestyle and even inserts markers when plotting multiple lines. If you want to make the second plot appear as the first one, then I suggest you use yyaxis but hide one of the axes.
yyaxis left
plot(rand(10,10))
yyaxis right
set(gca,'ycolor','none')
You could also grab the default settings of the yyaxis in your first graph
cs=get(gca,'colororder');
ls=get(gca,'linestyleorder')
ans =
7×2 char array
'- '
'--'
': '
'-.'
'o-'
'^-'
'*-'
and then simply apply them after toggling to your second graph
set(gca,'linestyleorder',ls)
set(gca,'colororder',cs)
Note that the yyaxis by default only has one colororder and multiple linestyleorders, whereas the normal plot has one linestyleorder and multiple colororders. By default, the first linestyle is plotted with each color, then the second linestyle is plotted with each colors and so on... This behaviour is controlled by the colororderindex and linestyleindex.