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!

采纳的回答

Manish
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 CenterFile Exchange 中查找有关 Scatter Plots 的更多信息

产品


版本

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by