具有颜色限制的 MATLAB 散点密度图

MATLAB scatter density plot with color restriction

我是 matlab 的新手,我知道它很简单,但我不知道要搜索什么..

我做了一个 x,y 散点图,效率为 (0~1)

 scatter(sun(:,1),sun(:,2),19, sun(:,3),'fill')

我的问题是如何限制颜色变化,例如从亮黄色到深红色,而不是从深蓝色到深红色,这是默认颜色。

我的另一个问题是,是否可以用黑线将每个数据点包围起来,让观众看得更清楚?

谢谢!

在阅读 "from bright yellow to dark red instead of from dark blue to dark red" 时,我认为最简单的解决方案是使用 built-in colormap hot 的有限(和翻转)版本而不是(R2014b 之前的)默认 jet。您可以限制 jet 但可能 运行 无意中变成其他颜色。

例如:

defaultHot = hot(100);  % changing 100 changes the number of gradations
colormap(defaultHot(80:-1:1,:)); % flip so smaller values are bright yellow

仅从 hot 颜色图函数中获取前 80 行,为小值颜色提供了丰富的黄色。使用整个颜色图会产生亮白色(您可能喜欢也可能不喜欢)。

此外,添加边界黑线的简单方法是使用 ('MarkerEdgeColor','k') scatter name-value pair。考虑样本输入

x = rand(n,1);
y = rand(n,1);
z = exp(-20*((x-1/2).^2+(y-1/2).^2));
scatter(x,y,19,z,'filled','MarkerEdgeColor','k');

colorbar(); % Show colorbar
caxis([0,1]); % Explicitly stretch the colormap to cover the entire range

这会产生情节