Plot graph using dots and colormap to show the frequency

14 vues (au cours des 30 derniers jours)
Arif Adam Bin Mohd Nor
Arif Adam Bin Mohd Nor le 2 Déc 2022
Hi, I have a set of data (x and y) and I would like to plot a graph using dots/scatter and a colormap to indicate the frequency/intensity of it happening. I used the code as shown below but I do not want the graph to be plotted in tiles because it would not be presentable in a semilog scale graph. So, instead of using tile, I would like the graph to be plotted in dots instead and the colormap to show the intensity. Thank you very much in advance.
hist=histogram2(x,y,[150,200],'DisplayStyle','tile');
c = colorbar;
colormap ('jet');

Réponses (1)

Shubham
Shubham le 19 Oct 2023
To plot a graph using dots/scatter and a colormap to indicate the frequency/intensity of the data points, you can use the scatter function in MATLAB. Here's an example of how you can modify your code:
% Sample data
x = [1, 2, 3, 4, 5];
y = [10, 20, 30, 40, 50];
intensity = [2, 5, 3, 7, 10]; % Intensity values for colormap
% Plotting with scatter and colormap
figure;
scatter(x, y, [], intensity, 'filled');
colormap('jet'); % Choose your desired colormap
colorbar; % Add a colorbar to show the intensity scale
% Additional plot settings
xlabel('X');
ylabel('Y');
title('Scatter Plot with Colormap');
Hope this helps.

Catégories

En savoir plus sur Colormaps dans Help Center et File Exchange

Produits


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by