How is the coordinates of X and Y in scatter for create this image?

2 views (last 30 days)
How is the coordinates of X and Y in scatter for create this image?

Answers (2)

Walter Roberson
Walter Roberson on 29 Apr 2018
yx = [1, 2, 2, 3, 1, 3, 1, 2, 3, 2];
yy = [1, 1, 2, 2, 3, 3, 4, 4, 4, 5];
bx = [1, 2, 4];
by = [2, 3, 3];
pointsize = 50;
scatter(yx, yy, pointsize, 'yo', 'filled', 'MarkerEdgeColor', 'k');
hold on
scatter(bx, by, pointsize, 'ko', 'filled');
hold off
axis equal
set(gca, 'YDir', 'reverse', 'color', [170 192 224]/255, 'xtick', [], 'ytick', [], 'XLim', [0.5 9.5], 'Ylim', [0.5 5.5])
Now you can scatter() in unfilled circles with color 'none' and 'markeredgecolor', 'k') for all of the other grid locations. With a couple of lines of work you can even compute where those locations are based upon yx, yy, bx, by.

Zwithouta
Zwithouta on 29 Apr 2018
Use this code/coordinates to create the figure
[x,y] = meshgrid([1:9], [1:5])
figure
hold on
for i = 1:size(x,1)
scatter(x(i,:),y(i,:), 'MarkerEdgeColor', 'k') % use plot function with 'o'-marker to avoid for loop
end
xfilled = [2 1 2 3 1 3 2 3 1 2];
yfilled = [1 2 2 2 3 3 4 4 5 5];
scatter(xfilled, yfilled, 'filled')
ylim([0 6])
xlim([0 10])
hold off

Tags

Community Treasure Hunt

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

Start Hunting!