Create unique areas around a marker on scatterplot

조회 수: 1 (최근 30일)
Eric Escoto
Eric Escoto 2019년 4월 22일
편집: Eric Escoto 2019년 4월 22일
Hello,
I've created a 2d scatterplot. My marker locations reference two vectors for x and y locations. The data is pulled into the plot and binned for each marker location. At the end, I wind up with a 2d scatter plot and a colorbar that correlates to the counts at each location. All is good.
However, this plot is difficult to interpret.
I would like the marker to extend in the 2d space to fill each box delineated by my xticks and yticks.
How can this be accomplished? Below is some helpful information about my process so far. The first portion creates the spatial locations (x and y) for the data to be plotted to.
% Class (col #) sizes (speed) and class spread:
% Class Mid-value [mm, m/s] spread [mm, m/s]
% 1 (3) 0.062 (0.050) 0.125 (0.100)
% 2 (4) 0.187 (0.150) 0.125 (0.100)
% 3 (5) 0.312 (0.250) 0.125 (0.100)
% 4 (6) 0.437 (0.350) 0.125 (0.100)
% 5 (7) 0.562 (0.450) 0.125 (0.100)
% 6 (8) 0.687 (0.550) 0.125 (0.100)
% 7 (9) 0.812 (0.650) 0.125 (0.100)
% 8 (10) 0.937 (0.750) 0.125 (0.100)
% 9 (11) 1.062 (0.850) 0.125 (0.100)
% 10 (12) 1.187 (0.950) 0.125 (0.100)
% 11 (13) 1.375 (1.100) 0.250 (0.200)
% 12 (14) 1.625 (1.300) 0.250 (0.200)
% 13 (15) 1.875 (1.500) 0.250 (0.200)
% 14 (16) 2.125 (1.700) 0.250 (0.200)
% 15 (17) 2.375 (1.900) 0.250 (0.200)
% 16 (18) 2.750 (2.200) 0.500 (0.400)
% 17 (19) 3.250 (2.600) 0.500 (0.400)
% 18 (20) 3.750 (3.000) 0.500 (0.400)
% 19 (21) 4.250 (3.400) 0.500 (0.400)
% 20 (22) 4.750 (3.800) 0.500 (0.400)
% 21 (23) 5.500 (4.400) 1.000 (0.800)
% 22 (24) 6.500 (5.200) 1.000 (0.800)
% 23 (25) 7.500 (6.000) 1.000 (0.800)
% 24 (26) 8.500 (6.800) 1.000 (0.800)
% 25 (27) 9.500 (7.600) 1.000 (0.800)
% 26 (28) 11.000 (8.800) 2.000 (1.600)
% 27 (29) 13.000 (10.400) 2.000 (1.600)
% 28 (30) 15.000 (12.000) 2.000 (1.600)
% 29 (31) 17.000 (13.600) 2.000 (1.600)
% 30 (32) 19.000 (15.200) 2.000 (1.600)
% 31 (33) 21.500 (17.600) 3.000 (3.200)
% 32 (34) 24.500 (20.800) 3.000 (3.200)
% I want to create a two sepearte 1 x 1024 matrices based on the mid-value size and
% velocity. These matrices are used to locate the RawData binned drop
% counts as my (x, y) positions with the counts as my z-values.
dropsizevect = [0.062, 0.187, 0.312, 0.437, 0.562, 0.687, 0.812, 0.937,...
1.062, 1.187, 1.375, 1.625, 1.875, 2.125, 2.375, 2.750,...
3.250, 3.750, 4.250, 4.750, 5.500, 6.500, 7.500, 8.500,...
9.500, 11.000, 13.000, 15.000, 17.000, 19.000, 21.500, 24.500];
dropsizevect = repelem(dropsizevect,32); % This repeats the values indiviually first 32 times and gives a 1024 x-axis vector
dropspeedvect = [0.050, 0.150, 0.250, 0.350, 0.450, 0.550, 0.650, 0.750, 0.850,...
0.950, 1.100, 1.300, 1.500, 1.700, 1.900, 2.200, 2.600, 3.000,...
3.4000, 3.800, 4.400, 5.200, 6.000, 6.800, 7.600, 8.800, 10.400,...
12.000, 13.600, 15.200, 17.600, 20.800];
dropspeedvect = repmat(dropspeedvect, 1, 32); % This repeats the entire set 32 times as a unit.
% Test scatter plot to show the locations of drops in the rainfall spectrum diagram. IT WORKS.
figure
scatter(dropsizevect, dropspeedvect);
This section takes the data and places in the locations created above. However, they plot as points. I want to plot each point as the rectangle created by the xticks and yticks.
% Now I have the (x, y, z) values (size, velocity, counts) for every
% timestamp and I can plot individual timestamps.
j = nansum(subSFL2019_P2_RawData{278}(:,3:end));
j(j == 0) = NaN;
% Plot testing
figure % Use the 'gscatter' function, with the '.' (point) marker. Colors correspond to drop counts with size = 15.
s = scatter(dropsizevect,dropspeedvect,500, j);
title('Rainfall Spectrum')
xlabel('Raindrop Size [mm]')
ylabel('Raindrop Speed [m/s]')
xlim([0 26])
ylim([0 22.4])
xticks([0 .1245 .2495 .3745 .4995 .6245 .7495 .8745 .9995 1.25 1.5 1.75 2.0 2.25 2.5 3.0 3.5 4.0 4.5 5.0 6.0 7.0 8.0 9.0 10.0 12.0 14.0 16.0 18.0 20.0 23.0 26.0])
yticks([0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.2 1.4 1.6 1.8 2.0 2.4 2.8 3.2 3.6 4.0 4.8 5.4 6.2 7.0 7.8 9.4 11.0 12.6 14.2 15.8 19.0 22.2])
colorbar
colormap('jet')
% lim = caxis;
% caxis([0 200])
m = s.Marker;
s.Marker = '.';
grid on
Here's an image of whats currently created.
test.bmp
I'll be happy to answer questions. Perhaps there's a better way of doing this that I'm unaware of as well. Thanks for the help.

답변 (0개)

카테고리

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