Plotting 5 different filled markers on one graph

Hi All,
I need to plot 5 sets of data on a one graph, I can plot the data but I can't not fill the markers. Is there a way to fill the different markers? I don't need the line contecting the points.
3 of the datasets contain 6 points, 1 constains 5 points and 1 contains 7. This is what I have, I need to fill in the markers and change the colours of the markers.
Thanks

 Risposta accettata

If you don’t need lines connecting the points, use the scatter function. It has a 'filled' option to automatically fill the markers.
x = 1:15;
y = randn(5,15);
figure
scatter(x, y, 'filled')
EDIT — (6 Aug 2022 at 14:44)
Added scatter plot.
.

6 Commenti

Alice K
Alice K il 6 Ago 2022
Modificato: Alice K il 6 Ago 2022
Scatter plot would not work as the data are different sizes, 3 is 6 sets of coordinates, 1 has 5 sets of coordinates and the last one has 7.
This is what I have, I need to fill in the markers and change the colours.
It would help to have the data and the code you used to plot it.
Try something like this —
x{1} = randi(600,6,3);
y{1} = randi(40,6,3);
x{2} = randi(600,5,1);
y{2} = randi(40,5,1);
x{3} = randi(600,7,1);
y{3} = randi(40,7,1);
mrkr = {'o' 'd' 's' 'v' '^' '<' '>'};
cm = colormap(turbo(3));
figure
hold on
for k = 1:numel(x)
scatter(x{k},y{k},75,cm(k,:),mrkr{k},'filled')
end
hold off
In the scatter call, the coordinates are the first and second arguments, the size third, colour fourth (here indexing into the colormap ‘cm’), the marker shape fifth, and 'filled' last.
.
My code for this was:
plot(C30Time,C30,'diamond',DECTime,DEC,'^', DESTime,DES,'v',JKSTime,JKS,'o',C20Time,C20,'s')
axis([0 640 0 40])
Here is my data:
C30 = [12,16,19,23,27]; % Green Diamond
C30Time = [48,99,147,297,578];
DEC = [24,24,26,28,30,32]; % Purple Up Triangle
DECTime = [36,43,57,117,179,298];
DES = [26,27,29,32,36,36]; % Yellow Down Triangle
DESTime = [32.9603,28.6877,43.3367,70.1933,297.253,598.779];
JKS = [29,31,34,36,36,36]; % Blue Circle
JKSTime = [36,48,87,149,348,500];
C20 = [17,22,25,27,28,29,30]; % Red Square
C20Time = [28,58,118,218,298,448,589];
I will give what you said a try.
Thank You
My pleasure!
Try this —
C30 = [12,16,19,23,27]; % Green Diamond
C30Time = [48,99,147,297,578];
DEC = [24,24,26,28,30,32]; % Purple Up Triangle
DECTime = [36,43,57,117,179,298];
DES = [26,27,29,32,36,36]; % Yellow Down Triangle
DESTime = [32.9603,28.6877,43.3367,70.1933,297.253,598.779];
JKS = [29,31,34,36,36,36]; % Blue Circle
JKSTime = [36,48,87,149,348,500];
C20 = [17,22,25,27,28,29,30]; % Red Square
C20Time = [28,58,118,218,298,448,589];
Timec = {C30Time; DECTime; DESTime; JKSTime; C20Time};
Datac = {C30; DEC; DES; JKS; C20};
mrkrc = {'d' '^' 'v' 'o' 's'};
cm = turbo(numel(Timec));
figure
% scatter(C30Time,C30,'diamond',DECTime,DEC,'^', DESTime,DES,'v',JKSTime,JKS,'o',C20Time,C20,'s')
hold on
for k = 1:numel(Timec)
scatter(Timec{k}, Datac{k}, 75, cm(k,:), mrkrc{k}, 'filled')
end
hold off
axis([0 640 0 40])
The colour order and colour map can be whatever you like. You should have turbo.
.
Your other code worked. Thank you so much.
As always, my pleasure!

Accedi per commentare.

Più risposte (0)

Prodotti

Release

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by