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

2 次查看(过去 30 天)
How is the coordinates of X and Y in scatter for create this image?

回答(2 个)

Walter Roberson
Walter Roberson 2018-4-29
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 2018-4-29
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

类别

Help CenterFile Exchange 中查找有关 Lighting, Transparency, and Shading 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by