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 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