Plot graph using dots and colormap to show the frequency

17 次查看(过去 30 天)
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');

回答(1 个)

Shubham
Shubham 2023-10-19
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.

类别

Help CenterFile Exchange 中查找有关 Colormaps 的更多信息

产品


版本

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by