Scatter plot with colormap and colorbar based on one of the parameters plotted
조회 수: 4 (최근 30일)
이전 댓글 표시
Hello everyone,
I want to plot three parameters using colored scatter plot where the colormap/colorbar represents the values of one of them. Attached file is the example of the datasets containing data_x, data_y, data_z. My intention is using the data_z as the colormap as well as colorbar of the scatterplot.
Thank you!
댓글 수: 0
채택된 답변
Manish
2024년 10월 9일
편집: Manish
2024년 10월 9일
Hi,
I understand that you want to plot a colored scatterplot with 'data_z' represented on the color map, and 'data_x' and 'data_y' on the other axes.
Here is the code implementation:
% Load the data from the .mat file
data = load('data_xyz.mat');
% Extract the variables
data_x = data.data_x;
data_y = data.data_y;
data_z = data.data_z;
% Create the scatter plot
figure;
scatter(data_x, data_y, 5, data_z, 'filled');
colorbar;
xlabel('Data X');
ylabel('Data Y');
title('Colored Scatter Plot with Z as Colormap');
colormap(jet)%optional
The above figure is the output of the code.
Here is the documentation link for Scatter plot:
Hope this solves!
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Scatter Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!