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!