Changing the colour of data points on a graph that satisfy a certain criteria

1 Ansicht (letzte 30 Tage)
So i basically calculate a probability and for data points that have a probability of say 0.8 i want to change the colour on the graph, what function do i use to do this? i have tried using the set function but dont seem to be able to get it to work

Antworten (1)

bym
bym am 3 Nov. 2012
There are many ways of doing this. Here is one
clear;clc
x = rand(2000,1);
y = rand(2000,1);
c = hypot(x -.5,sqrt(y)-1.25*y) > .2;
plot(x(c),y(c),'b.',x(~c),y(~c),'r*')
axis square
  1 Kommentar
Matt
Matt am 4 Nov. 2012
%=========================================================================% % Searching for Clusters % %=========================================================================% % % % Import Data manually % By Matthew Crouch 26.09.2012 % Import Data Manually
%% Determination of Data
n =300 ; %Number of Stars in the Cluster Field m = 2905; %Number of Stars in the Control Field
D = data; %Reads 2MASS data jmag = D(:,1); %(:,n) reads the nth colomn hmag = D(:,2); k1mag = D(:,3); diffmag = (jmag-k1mag); diffmag2= (jmag-hmag); diffmag3= (hmag-k1mag);
kmag = find(k1mag < 10); % Eliminates any stars with mag greater than 10 mag
Ra5= Arc5(:,9); Dec5=Arc5(:,10); Ra9=Arc9(:,9); Dec9=Arc9(:,10);
Cfjmag = CF(:,1); %2MASS control Field Cfhmag = CF(:,2); Cfkmag = CF(:,3); Cfdiffmag = (Cfjmag - Cfkmag); Cfdiffmag2 = (Cfjmag - Cfhmag); Cfdiffmag3 = (Cfhmag - Cfkmag);
%% Calculating Cluster Probability %%3D Elipsoid
rccm = zeros(n,n); Crccm = zeros(n,m); CNccm = zeros(n,m); Nccm = zeros(m,1); Prob = zeros(n,1);
for i=1:1:n for j=1:1:n; rccm(i,j) = sqrt((0.5*(jmag(i,1)-jmag(j,1)).^2)+((diffmag(i,1)-diffmag(j,1)).^2)+((diffmag2(i,1)-diffmag2(j,1)).^2)); hold on end end
srt = sort(rccm); %Put in value of the 15th star r = transpose(srt(11,1:n)); %Radius of the 11 star
for i=1:1:n; for k=1:1:m; Crccm(i,k) = sqrt((0.5*(jmag(i,1)-Cfjmag(k,1)).^2)+((diffmag(i,1)-Cfdiffmag(k,1)).^2)+((diffmag2(i,1)-Cfdiffmag2(k,1)).^2)); end rcontr = transpose(Crccm); CNccm = (rcontr(:,i)) <= r(i,1); Nccm(i) = sum(CNccm); Prob(i)= 1-((Nccm(i)/10)*(9/81));
hold on
end
%% Plotting Of Graphs
figure(1) scatter(diffmag,k1mag, 'xk'); set(gca,'YDir','Reverse'); xlabel '(J-K) Magnitude', ylabel 'K Magnitude', title ' Colour Magnitude Diagram around .....'; %Change Cluster Name Where appropriate
figure(2) scatter(diffmag3,diffmag2,'xr');
xlabel '(H-K) Magnitude', ylabel '(J-H) Magnitude', title 'Colour Colour Diagram around .....'
figure(3) scatter(Cfdiffmag,Cfkmag, 'xb'); set(gca,'YDir','Reverse'); xlabel '(J-K) Magnitude', ylabel 'K Magnitude', title ' Colour Magnitude Diagram around .....(Control Field)';
figure(4) scatter(Cfdiffmag3,Cfdiffmag2,'xm');
xlabel '(H-K) Magnitude', ylabel '(J-H) Magnitude', title 'Colour Colour Diagram around ..... (Control Field)'
figure(5) scatter(Ra5,Dec5,'xk'); hold on xlabel 'RAJ200', ylabel 'DECJ2000',
figure(6) scatter(Ra9,Dec9,'xb'); hold on xlabel 'RAJ200', ylabel 'DECJ2000',
Above is a copy of my code. I am trying to identify members that have a probability over 0.8 then colour them red, then values with a prob between 0.6-0.8 another colour etc etc...how do i do this?

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Particle & Nuclear Physics finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by