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 Center および File ExchangeLighting, Transparency, and Shading についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by