Hello,
I'm trying to plot in 2D some points and I want to color them depending on a logic (1 or 0) classification.
I'll explain myself better. I have a matrix with different xy-coordinates and a logic values assigned to each coordinate that tells me if the point is suitable as an initial points for the deployment of a satellite. I've tried using scatter but I just get colored points and I'm looking for a "painted map" so I can easily see groups of good points and groups of bad points.
EDIT: I want to see a colored, continuum surface indicating "good" zones and "bad" zones depending of if there are many suitable points or not. Something like this image.
Thank you guys.

 채택된 답변

Star Strider
Star Strider 2015년 8월 11일

0 개 추천

If you already know the ‘good’ and ‘bad’ points, and they are defined by logical indexing, use the logical index values to separate them into the appropriate vectors, use the hold function, and plot them:
x = 1:100;
y = randi(99, 1, 100);
select = y > 75; % logical Selection Vector
good_pts = y(select);
bad_pts = y(~select);
figure(1)
scatter(x(select), good_pts, 'bp')
hold on
scatter(x(~select), bad_pts, 'rp')
hold off
grid
legend('Good Points', 'Bad Points')

댓글 수: 4

Felix Lauwaert
Felix Lauwaert 2015년 8월 11일
Thanks, this way I can use scatter with better colors than I used to, but this doesn't solve my problem. I want to plot a coloured "sheet", I don't want to see the points in my plot but a surface of "inifinite" points, something like a density map.
Star Strider
Star Strider 2015년 8월 11일
You said in your Question that you have 2D points. You can’t define a surface with only two dimensions of (x,y) coordinates.
Felix Lauwaert
Felix Lauwaert 2015년 8월 12일
I have 2D points but with a binary value assigned to them.
Imagine:
oooooxooooo
ooooxxxoooo
oooooxooooo
So I need a graph that paints 'x' zone in one color and 'o' zone in another. I don't care if it's 3D like surf or just like the image I linked in my question.
Star Strider
Star Strider 2015년 8월 12일
편집: Star Strider 2015년 8월 12일
The image you linked to is a contour plot.
See the contour function (and its friends, including ‘Contour Properties’) for details.
Your data would have to be in a matrix for it to work as you want it.
For example:
M = zeros(10);
M(3:6, 3:6) = 1;
figure(1)
contourf(M) % Filled Contour Plot
figure(2)
contourf(M, 1) % Filled Contour Plot Specified With One Contour
EDIT — Added plot.

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Image Analyst
Image Analyst 2015년 8월 11일

0 개 추천

scatter() should still work. What did you do? You can pass in a list of colors for every point you know. You can also determine the sizes that way. Did you pass colors and sizes in to scatter(), or you just passed in x and y? You'd need to have an array with as many rows as you have data points, and three columns, with the values in the columns being in the range 0-1.

댓글 수: 1

Felix Lauwaert
Felix Lauwaert 2015년 8월 11일
Yes but I don't want a point plot, I want a surface plot...

댓글을 달려면 로그인하십시오.

Bjorn Gustavsson
Bjorn Gustavsson 2015년 8월 11일

0 개 추천

Well if you really want a surface-type plot look at trisurf and possibly TriScatteredInterp, if you prefer to first reinterpolate your goodness onto a regular grid.
HTH

카테고리

질문:

2015년 8월 11일

편집:

2015년 8월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by