Korzystanie gscatter
, co robi wykres punktowy, wykorzystując grupę (Label
w danym przypadku) do działki w różnych kolorach/twórców.
GSCATTER(X,Y,G,CLR,SYM,SIZ) specifies the colors, markers, and
size to use. CLR is either a string of color specifications or
a three-column matrix of color specifications. SYM is a string
of marker specifications. Type "help plot" for more information.
For example, if SYM='o+x', the first group will be plotted with a
circle, the second with plus, and the third with x. SIZ is a
marker size to use for all plots. By default, the marker is '.'.
Tak można określić kolory takie jak czerwony 'rgcmykwb'
zrobić dla pierwszej grupy, zielony na sekundę, etc lub []
tylko mieć Matlab układać.
Domyślnie Matlab używa tego samego znacznika dla każdej grupy, więc musisz określić, które znaczniki mają być używane dla każdej grupy. Jeśli zrobisz '.ox+*sdv^<>ph'
, po prostu przejdziesz wszystkie znaczniki, które ma Matlab.
n=50;
% make nx2 matrix of random points.
points = random('unif',0,1,n,2);
% make nx1 matrix of random labels from {1,2,...,5}
labels=round(random('unif',1,5,n,1));
% plot. Let Matlab sort out the colours and we will specify markers.
gscatter(points(:,1),points(:,2),labels,[],'ox+*sdv^<>ph.')
wygląda nieco jak poniżej:
możliwe duplikat [warunkowego rozrzut Matlab] (http://stackoverflow.com/questions/8533136/conditional-scatter-in-matlab) – yuk