Plot data with different colors and line styles

I have a matrix, data of size nxm I want to plot the plot first and second half of data with different colors.
For example:
data(1:10,1) and data(1:10,2) color1.
data(11:20, 1) and data(11:20, 2) color2
At the same time, the line style of data(:,1) should be different than data(:,2).
I have done the first part, but, i do not know how to do both together (different colors and shapes)
data = [ 0.731188434558433 2.41513916177898;
0.366001269448802 3.37392834903599;
0.943817657785536 5.66390191537987;
0.117683309809527 36.8308292738086;
0.340853677642194 8.63449510675277;
0.573396508159045 9.70286440836929;
0.304203558495861 15.6847404386995;
0.122128705500944 47.2640549996507;
0.349427840163991 3.38714374855192;
0.289026464797605 9.89066493345409;
0.962128829519775 1.30130847811064;
0.171298885466281 6.65453532178612;
0.876922210736022 3.04095091117007;
0.215641729199285 16.7684559177041;
0.139227715586794 17.8163968051408;
0.215742495002276 4.64280472608912;
0.105551924042310 10.6083991416122;
0.429272258677111 7.75591399318736;
0.454819968706234 2.21457707709575;
0.186025212468652 14.9782095854468];
figure; cla;
PlotStyle = {'kd', ...
'LineWidth', 1,...
'MarkerEdgeColor', 'k',...
'MarkerFaceColor', 'g',...
'MarkerSize',6};
Points = [0.15 5 ; 0.6 2];
plot(Points(:,1), Points(:,2), PlotStyle{:});
hold on
ix = [ 1:10; 11: 20];
colors = ['o' 'b'; 'o' 'r'];
hLine1 = plot(nan, nan, colors(1,:));
hLine2 = plot(nan, nan, colors(2,:));
t = 1;
while t < 100
set(hLine1, 'XData', data(ix(1,:),1), 'YData', data(ix(1,:),2));
set(hLine2, 'XData', data(ix(2,:),1), 'YData', data(ix(2,:),2));
pause(0.001)
xlim([0 max(data(:,1)+0.2)]);
drawnow
% here code to upadate data
t = t+1;
end

Catégories

En savoir plus sur Creating, Deleting, and Querying Graphics Objects dans Centre d'aide et File Exchange

Produits

Version

R2017a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by