Hi Iron,
I understand that you want to visualize the density of data points using concentric ellipses with varying color intensity. Here is a MATLAB approach using the contourf function to achieve this effect:
- Calculate the density of data points.
- Use contourf to create the density plot.
- Overlay different datasets using hold on.
Here's how you can implement this:
% Assuming you have three sets of data: Pristine, Neutron, and Amorphous
% For demonstration, let's create some random data
% Replace these with your actual data
x1 = randn(100, 1) + 8; y1 = randn(100, 1) + 10; % Pristine
x2 = randn(50, 1) + 9; y2 = randn(50, 1) + 9; % Neutron
x3 = randn(30, 1) + 11; y3 = randn(30, 1) + 12; % Amorphous
% Combine data for contour plot
x = [x1; x2; x3];
y = [y1; y2; y3];
% Create a grid for the density plot
xGrid = linspace(min(x), max(x), 100);
yGrid = linspace(min(y), max(y), 100);
[X, Y] = meshgrid(xGrid, yGrid);
% Calculate density using ksdensity
density = ksdensity([x, y], [X(:), Y(:)]);
density = reshape(density, size(X));
% Plot density using contourf
figure;
contourf(X, Y, density, 20, 'LineColor', 'none'); % 20 levels
colorbar;
hold on;
% Overlay original data points
scatter(x1, y1, 'bo'); % Pristine
scatter(x2, y2, 'rx'); % Neutron
scatter(x3, y3, 'g*'); % Amorphous
% Set labels and title
xlabel('Entropy of FFT domain (medium frequency)');
ylabel('Entropy of DCT domain');
title('Scatter plot with density overlay');
% Add legend
legend('Density', 'Pristine', 'Neutron', 'Amorphous');
hold off;
For more information on the functions used:
- contourf: https://www.mathworks.com/help/matlab/ref/contourf.html
- ksdensity: https://www.mathworks.com/help/stats/ksdensity.html
- scatter: https://www.mathworks.com/help/matlab/ref/scatter.html
Hope this helps.
Regards,
Nipun