Best way to display 3 variables with a scatter plot

14 次查看(过去 30 天)
Hello everyone,
I am dealing with a small problem, and maybe some of you may have a better idea than me. So here is the story: I am having large datasets to display. By large I mean between 4K to 10K dots. I am using a scatter plot for that. I plot Y as a function of X and so far the results/display are ok. But I'd like to add the Z variable on the top of that.
My original idea was to display Z as a color variation. it goes from x.10-4 to ~5, and most of my values are very low: the result was few dots were yellowish and the rest was dark blue.
The second idea was to display the first, second and third quartile, with a color for each of them. I lose in resolution but I would have roughly my lower values in let's say blue, then red for 50% of my data, and finally the last 25% would be green. Here again the density of dots makes the graph difficult to read: the green is on the top of the red which is on the top of the blue....
Can I control the alpha with a scatter plot (as far as I've searched, I don't think so). Do you think of a better idea to display amount of dots in respects of the Z variable?
Here is my code :
temp = [X,Y,Z];
temp3= sortrows(temp,3);
N = length(X);
Q1= ceil(N/4);
Q3=ceil((3*N)/4);
a1=temp3(1:Q1,1);
b1=temp3(1:Q1,2);
c1=temp3(1:Q1,3);
a2 = temp3(Q1:Q3,1);
b2= temp3(Q1:Q3,2);
c2 = temp3(Q1:Q3,3);
a3=temp3(Q3:N,1);
b3=temp3(Q3:N,2);
c3=temp3(Q3:N,3);
figure();
scatter(a1(:),b1(:),10,c1(:), 'O', 'filled', 'b');
hold on;
scatter(a2(:),b2(:),10,c2(:), 'O', 'filled', 'r');
hold on;
scatter(a3(:),b3(:),10,c3(:), 'O', 'filled', 'g');
hold on;
axis( [0 1 1 5]);
Thank you for your help. Let me know if you need further information :)
Cheers, Flo
  5 个评论
mbonus
mbonus 2016-9-12
To the best of my knowledge it's not a function in MATLAB but Excel does have it. For every x value you would find a percentage confidence value. This value is how much you can reasonably expect your data to deviate from the average with the confidence chosen. If you vectorize the calculation then you can plot it without a loop.

请先登录,再进行评论。

回答(1 个)

Walter Roberson
Walter Roberson 2016-9-13
scatter() does not allow the alpha to be controlled on a per-point basis. It does, however, allow you to pass 'MarkerEdgeAlpha' and 'MarkerFaceAlpha' as scalars that affect all points drawn with that call.
  2 个评论
Flo
Flo 2016-9-13
I tried to play with those two parameters already, but they didn't permit me to access the dot properties.
Walter Roberson
Walter Roberson 2016-9-13
Which MATLAB version are you using? And please explain what you mean about "access dot properties"

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Discrete Data Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by