matlab - 如何在matlab中的散点图上显示颜色渐变?

标签 matlab visualization matlab-figure scatter

我有一个散点图,它将覆盖几组数据。每组数据当前显示为默认颜色图中的下一个颜色。这是我现在的代码:

figure
hold on
for i=1:10
   scatter(RunRawArea(i,:), RunRawNetLength(i,:));
end
hold off

我想要的是将每组数据(由 i 索引)进行颜色编码,使其成为渐变上的下一个颜色。例如,i=1 的数据为蓝色,i=5 的数据为紫色,i=10 的数据为红色。

我怎样才能做到这一点?

最佳答案

您应该向 scatter 添加另一个参数 - 称为 CData

https://www.mathworks.com/help/matlab/ref/scatter.html

Description: scatter(x,y) creates a scatter plot with circles at the locations specified by the vectors x and y. This type of graph is also known as a bubble plot.

在您的示例中:

figure
hold on
colorVec = linspace(1,0, size(RunRawNetLength,1));
colorVec = transpose(colorVec);
colorVec = repmat(colorVec,[1 3]);
for i=1:10
   scatter(RunRawArea(i,:), RunRawNetLength(i,:),'CData', colorVec );
end
hold off

关于matlab - 如何在matlab中的散点图上显示颜色渐变?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11384692/

相关文章:

matlab - 如何检查结构中的所有数组是否具有相同的大小

matlab - 如何在 MATLAB 中将矩阵变为 1+j、1-j、-1+j、-1-j

hadoop - 3D 渲染工具

matlab - 如何在 Matlab 中绘制对角直方图

Matlab cell2mat错误: all contents of the input cell array must be of the same data type

c# - 使用 c# 的输出作为 MATLAB 的输入

git - 如何仅使用分支名称而不是单个提交来鸟瞰 git 树?

python - 如何绘制不同训练样本的置信区间

matlab - 是否有可能绕过 MATLAB 对矢量格式文件中字体嵌入的限制?

matlab - MATLAB 图像顶部和底部的标题