# How to associate and color points based on distance or search radius and contour them?

4 visualizzazioni (ultimi 30 giorni)
Abdelrahman Abdeltawab il 26 Nov 2016
Commentato: Xel Ch il 27 Giu 2018
I have scatter plot shown in first image
what is the best method to reach the result in second image?
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Risposte (1)

Jose Lara il 5 Dic 2016
Abdelrahman, if you know the temperature for each of the coordinate given, you could create your own gradient of color.  If you have a matrix with the coordinates, for example:
coords = [1 2 3 4 5 6 7 8; 2 5 7 8 9 9 0 3];
then you may iterate through each point and designate it's own color depending on the resulting temperature. If the equation for the temperature is as follows:
T = x^2 +y/2 +1;
using a for loop, you can iterate through each point and plot with the correct color. Example code is shown below:
for i = 1:8 %number of coordinates
hold on
xi = coords(1,i);
yi = coords(2,i);
T =  xi^2 + yi/2 +1;
if T > 10;
plot(xi,yi,'ko')
elseif (T<10) && (T>8)
plot(xi,yi,'bo')
elseif (T<8) && (T<4)
plot(xi,yi,'ro')
else
plot(xi,yi,'go')
where the third argument of the ''plot'' function will be the color of the point and the marker type. You may separate the temperatures with more colors by using a RGB color values such as [1 0 0] for red and [1 1 1] for white.
##### 2 CommentiMostra NessunoNascondi Nessuno
Abdelrahman Abdeltawab il 6 Dic 2016
Thanks alot Jose, but my what i wanted is for each point in the scatter find the nearby points and cluster them or highlight them
Xel Ch il 27 Giu 2018
Hi Abdelrahman. I am looking to do something similar in Matlab, so was wondering if you were ever able to get this issue resolved? And if so, what did you do? Thank you!

Accedi per commentare.

### Categorie

Scopri di più su Scatter Plots in Help Center e File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by