Plot graph using dots and colormap to show the frequency

17 Ansichten (letzte 30 Tage)
Arif Adam Bin Mohd Nor
Arif Adam Bin Mohd Nor am 2 Dez. 2022
Beantwortet: Shubham am 19 Okt. 2023
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');

Antworten (1)

Shubham
Shubham am 19 Okt. 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.

Kategorien

Mehr zu Colormaps finden Sie in Help Center und File Exchange

Produkte


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by