필터 지우기
필터 지우기

Best to represent two large data sets in one plot

조회 수: 3 (최근 30일)
Flo
Flo 2016년 8월 26일
댓글: Image Analyst 2016년 8월 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에서 Visual Exploration에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by