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

조회 수: 1 (최근 30일)
hamid bs
hamid bs 2018년 4월 29일
답변: Zwithouta 2018년 4월 29일
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