Best to represent two large data sets in one plot

1 次查看(过去 30 天)
Hi everyone,
I am dealing with a scatter plot on which I'd like to plot two data sets containing at least 1500 dots per dataset. This number can reach 10000.
So far I am plotting those points by using a scatter plot:
Do you think Matlab offers a better way to show my data?
Thank you, Flo

回答(1 个)

Image Analyst
Image Analyst 2016-8-26
Depends on what you want to do or show. One option is you could create an image where you put one set into the red channel and one into the blue channel. Then you could increment a pixel to make it brighter when you happen to have multiple data values with the same x,y location. It will also let you see both sets at the same time (overlaps will be purplish) instead of the blue set, which you plotted last, covering up and totally obscuring the red data.
  2 个评论
Flo
Flo 2016-8-29
Interesting way of doing it. I will try to find out how to do that. thank you
Image Analyst
Image Analyst 2016-8-30
Try to adapt this:
fontSize = 15;
numPoints1 = 5000;
set1x = rand(numPoints1, 1);
set1y = 25 * rand(numPoints1, 1);
numPoints2 = 4000;
set2x = rand(numPoints2, 1);
set2y = 25 * rand(numPoints2, 1);
subplot(2, 2, 1);
plot(set1x, set1y, 'r.');
hold on;
plot(set2x, set2y, 'b.');
grid on;
title('Scatterplot', 'FontSize', fontSize);
% Make an image
rows = 300;
columns = 400;
redChannel = zeros(rows, columns);
blueChannel = zeros(rows, columns);
maxX1 = max(set1x);
maxY1 = max(set1y);
maxX2 = max(set2x);
maxY2 = max(set2y);
% Assign set 1 to red channel
for k = 1 : numPoints1
thisX = round(set1x(k) * columns / maxX1);
thisY = round(set1y(k) * rows / maxY1);
if thisX < 1
thisX = 1;
end;
if thisY < 1
thisY = 1;
end;
redChannel(thisY, thisX) = redChannel(thisY, thisX) + 1;
end
subplot(2,2,2);
imshow(redChannel, []);
title('Set 1', 'FontSize', fontSize);
% Assign set 2 to blue channel
for k = 1 : numPoints2
thisX = round(set2x(k) * columns / maxX2);
thisY = round(set2y(k) * rows / maxY2);
if thisX < 1
thisX = 1;
end;
if thisY < 1
thisY = 1;
end;
blueChannel(thisY, thisX) = blueChannel(thisY, thisX) + 1;
end
subplot(2,2,3);
imshow(blueChannel, []);
title('Set 2', 'FontSize', fontSize);
% Make RGB image
rgbImage = cat(3, mat2gray(redChannel), zeros(rows, columns), mat2gray(blueChannel));
subplot(2,2,4);
imshow(rgbImage, []);
title('both in an RGB image', 'FontSize', fontSize);

请先登录,再进行评论。

类别

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

Community Treasure Hunt

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

Start Hunting!

Translated by