You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
How to determine the different colour in scatter plot?
1 view (last 30 days)
Show older comments
Hi Everybody,
Could you please help me how I can show it with different color? refer to the below code? this code show in one color while I need to determine different satellite by different color.
17 Comments
Walter Roberson
on 13 Dec 2012
Why are you bothering to compute y, as you are not using it?
You are placing the circles in the same place each time, just with different sizes.
Ara
on 13 Dec 2012
Edited: Walter Roberson
on 13 Dec 2012
Ok, thanks. But still the problem is they plot all of the in a same color.
hold on
scatter (longi, lati, s4_0*2500, 'r')
hold on
scatter (longi, lati, s4_0*2500, 'g')
still plot it in a same color. It shows 5 different separated circle plot and the interesting thing is plot the second color. I mean green one as if can noot read the first line.
Azzi Abdelmalek
on 13 Dec 2012
Edited: Azzi Abdelmalek
on 13 Dec 2012
You are just erasing the previous scatter. What you can do is to scatter the biggest circle then the smallest
Walter Roberson
on 13 Dec 2012
You are plotting two circles of the same size at the same location. Only the second one is going to show up.
Ara
on 17 Dec 2012
Edited: Ara
on 17 Dec 2012
Thank you both, but still was not able to plot it with different color. I have another question, how can I try making plots with different threshold values. Since Walter helped me how to plot a point for each x value to calculated. Then draw a circle around x point. But NOW I want to get ride of small circle and just draw a circle for x data greater than some threshold value. For ex., x >=0.2. Could you please help me how?
Walter Roberson
on 17 Dec 2012
idx = s4_0(1,:) >= 0.2;
scatter(longi(idx), lati(idx), s4_0(1,idx)*2500,'r');
Ara
on 17 Dec 2012
Thank you, Walter. This code is good but the plot shows the same size for all of the circle while I am sure the column include the range of data between 0.2 to 0.5 and I would like to show it this range by different radius of the circles. As for color plot, I try this code and plot it colourful which is nice but I am not sure is correct so I put it here if it's possible for you to check it please. This code shows different trajectory of satellite in different color but still don't know which color is for which satellite or (prn) since legend also just show one data. I would really appreciate for your help.
scatter(longi, lati, s4_0*2500,prn(:,1));
Ara
on 19 Dec 2012
Thank you, but the problem is when I use it both figure are same which means there is no different between min and max. You know, the data are huge so I am just try to get rid of the small circle and just show the biggest (range 0.2, 0.3 and 0.4) one that was why I think to put some threshold and I expected to have a figure with some circle at least 6 circles and of course with different radius that I can show in this figure the different location of the biggest and smallest circles. But the below code just show me the same size and still lots of circles. could you please help me again if its possible?
idx = s4_0(1,:) >= 0.2;
scatter(longi, lati, max (s4_0(1,:))*2500,prn);
figure;scatter (longi, lati, min (s4_0(1,:))*2500,prn);
Walter Roberson
on 19 Dec 2012
My previous code
idx = s4_0(1,:) >= 0.2;
scatter(longi(idx), lati(idx), s4_0(1,idx)*2500,'r');
does use different radius of the circle. The s4_0(1,idx)*2500 expression is in the point-size parameter location, and the idx is selecting only those locations with the minimum radius.
But are you sure that the min() and max() are the same value ? Please show
format long g
min(S4_0(1,:))
max(S4_0(1,:))
Ara
on 19 Dec 2012
Yes, exactly same value...Do you remembered I upload a figure that shows some circle with different radius and it was about 6 circles. But in my data shows many many circles and when I show the point of each circle they look as if line so I prefer to reduce it and make the figure more clear.
ans =
0.0688228888887992
ans =
0.0688228888887992
Walter Roberson
on 19 Dec 2012
If all of your values are the same, then what value should be used to figure out the size of the circle? Or are the values just all the same for each column, but different between the columns? Are all the values in any one column certain to be the same?
Ara
on 19 Dec 2012
All the value are just for one column (one day data). Just imagine one column with different values and it might just 5 values (may one 0.2 and two 0.3 and two 0.4) in one column which are important to show.So I want to show by circle to clarify the exact value.I am also wondering cause when I plot it without threshold, it shows me some circles with different sizes so I want to extend it for whole month and I need to reduce extra circle just the significant one is important to me.
Walter Roberson
on 19 Dec 2012
I am confused.
Oh wait, row vs column. S4_0(1,:) is a row, not a column. Okay, so are all the values for one row the same, but the values might differ between rows??
Ara
on 19 Dec 2012
Sorry to make you confused. I am work just with column not row.I want Matlab read column s4 which I wrote and show different value by circle.
data=xlsread('1615_0.xls');
data_filterr=find(data(:,25)>60);
data_filtered=data(data_filterr,:);
elev_cutof20=find(data_filtered(:,6)>30);
data_cutoff15=data_filtered(elev_cutof20,:);
r=data_cutoff15(:,2);
time=(r./3600)-(24*0);
s4r=data_cutoff15(:,8);
s4cor=data_cutoff15(:,9);
s4=sqrt(s4r.^2-s4cor.^2);
Walter Roberson
on 19 Dec 2012
I'm not sure how s4_0 fits into this? Your s4 here would be a single column, but your s4_0 in your previous code was multiple columns.
Presuming that lati and longi are filtered the same way as data_filter, then it looks like you would want
idx = s4 >= 0.2;
scatter(longi(idx), lati(idx), s4(idx)*2500,'r');
Ara
on 19 Dec 2012
Thank you. It works. Just please let me ask another question regarding to different color. Assume all are filtered the same way. Each PRN in the column has different value and repeated by time and s4 column relevant to those number. I mean PRN shows number of satellite and I want to determine the circle by color to show come from which number. PRN=data_cutoff15(:,3);
Accepted Answer
Walter Roberson
on 19 Dec 2012
Are the PRN numbers simple integers such as 1, 2, 3, 4, 5, 6 ?
numsat = max(PRN);
cmap = jet(numsat); %use any handy colormap
idx = s4 >= 0.2;
scatter(longi(idx), lati(idx), s4(idx)*2500, cmap(PRN(idx),:) );
1 Comment
More Answers (0)
See Also
Categories
Find more on Mapping Toolbox in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)