Plot graph using dots and colormap to show the frequency

17 ビュー (過去 30 日間)
Arif Adam Bin Mohd Nor
Arif Adam Bin Mohd Nor 2022 年 12 月 2 日
回答済み: Shubham 2023 年 10 月 19 日
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 Center および File ExchangeColormaps についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by