How to fill a graph exclusing given points?

2 ビュー (過去 30 日間)
Anna
Anna 2019 年 9 月 19 日
回答済み: Steven Lord 2019 年 9 月 20 日
If a graph has a cluster of points, I want the graph to be filled such that every other point except the cluster is coloured
  8 件のコメント
Adam Danz
Adam Danz 2019 年 9 月 19 日
If you have the coordinates of the cluster boundary, you can use the axis limits to create a match with the empty cluster region.
Here's an example
Anna
Anna 2019 年 9 月 20 日
Thank you

サインインしてコメントする。

採用された回答

Steven Lord
Steven Lord 2019 年 9 月 20 日
Let's make a random (well, not so random, more arbitrary) polygon.
A = nsidedpoly(5, 'Center', [1 1], 'Radius', 2);
If you wanted to enclose a non-regular region you can use polyshape instead of nsidedpoly (in fact nsidedpoly makes a polyshape.) Plot it and make it red.
p = plot(A, 'FaceColor', 'r');
Find the axes that contains the plotted polygon.
ax = ancestor(p, 'axes');
Make the axes background cyan.
ax.Color = 'c';
Because the plotted polygon is translucent you can see the cyan background "through" it, which makes it look very not red. Let's make it fully opaque so you can't see the background through it.
p.FaceAlpha = 1;
There we go; red pentagon on a cyan background.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by