Include occurrence frequency in Scatter plots

5 views (last 30 days)
Objective of the question is -
  • To include the occurence number in the scatter plot (image attached).
  • I have reached up to a level but not able to think how to include the numbers and color shades in it. I am attaching the two variables (x and y) for the purpose of understanding.
I wish the final image to look as the image attached (objective_image.jpeg)
  • numbers in each cell indicate the simultaneous occurrence of x and y axis
Kindly help.
Here in objective_image.jpeg the counts represents the simultaneous occurence frequency of x and y axis.
load swh_mwp_loc.mat
% For scatter plot
%%%%%%%%%%%%%%%%%%
AB =[swh_loc mwp_loc];
[uniqueAB, ~, n] = unique(AB, 'rows');% uniqueAB contains unique combination in which the AB can be grouped
% n contains each row of AB belongs to which uniqueAB
nHist = hist(n, unique(n)); % nHist contains frequency of occurence each of the 90 uniqueAB
scatter(uniqueAB(:, 2),uniqueAB(:, 1), 25,'filled');
% for contour plotting
%%%%%%%%%%%%%%%%%%%%%%%
hold on
x = mwp_loc(:,1) ;
y = swh_loc(:,1) ;
z = power_loc(:,1) ;
nx = 1000 ; ny = 1000 ;
[X,Y] = meshgrid(linspace(min(x),max(x),nx),linspace(min(y),max(y),ny)) ;
%Z =griddata(x,y,z,X,Y) ;
Z = 0.549*X.*Y.*Y;
[M,c]=contour(X,Y,Z,'--') ;
set(c,'ShowText','on')
c.LineWidth = 1; % for result up to here image is attached (scatter_plus_contour.jpg)

Answers (0)

Products


Release

R2018b

Community Treasure Hunt

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

Start Hunting!