I am plotting two sets of data with each set containing a 6 by 100 matrix. I would like the final plot to have 6 solid lines colored using the default color order. And 6 dashed lines colored using the default color order. However, when I use the command yyaxis left and yyaxis right, the default color and linestyles are changed. I've figured out how to override the colors by manually changing them using the plot command. I've tried to override the line style for the yyaxis right plot using 'LineStyle','–' in the plot command. Lines 1 through 4 come out the way I want, but lines 5 and 6 are dashed with the default line marker circle and triangle. How do I get rid of these default markers? Thank you in advance.
MATLAB version: R2017a OS: Windows 10 x64
figure(4) hold on
% colorVec = {'k', 'b', 'r', 'm', 'g', 'c'}; % linVec = {'–', '–','–', '–','–', '–'}; ,'Color', colorVec{i},'LineStyle',linVec{i} % delete( findobj(gca, 'type', 'marker') ); % yyaxis left %plot on left Y axis ax = gca;
co = [0 0.4470 0.7410; 0.8500 0.3250 0.0980; 0.9290 0.6940 0.1250; 0.4940 0.1840 0.5560; 0.4660 0.6740 0.1880; 0.3010 0.7450 0.9330; 0.6350 0.0780 0.1840]; set(groot,'DefaultAxesColorOrder',co)
for i = 1:nmat ax.ColorOrderIndex % plot(tvar,Ts1(i,:),'Color', co(i,:),'LineWidth',2) plot(tvar,Ts1(i,:),'Color', ax.ColorOrder(ax.ColorOrderIndex,:),'LineWidth',2) % hold on %hold commnd retains the current color order % plot(tvar,Ts2(:,:),'–','LineWidth',2,'MarkerSize',5) end
xlim([0 60]) grid on y_label = ylabel('Surface Temp [C]'); ax = gca; % current axes % ax.YAxis(1).TickLabelFormat = '%.2f'; ax.YAxis(1).Color = 'k'; %axis color
% figure(4) % ax.ColorOrderIndex = 1; %restarts the color order index before each plotting command
yyaxis right %plot on right Y axis for i = 1:nmat plot(tvar,driftT2(i,:),'Color', co(i,:),'LineStyle','–','LineWidth',2) end
y_label = ylabel('Thermal Drift [mrad]'); ax.YAxis(2).Color = 'b'; %axis color % ax.YAxis(2).TickLabelFormat = '%,d'; % ax.YAxis(2).Exponent = 0; hold off
Best Answer