使用 Quiver 函数在 Matlab 中更改矢量箭头的颜色
Change Color for Vector Arrows in Matlab Using Quiver Function
我在 Matlab 上有以下代码
x = [0.49015734, 0.04615336, 0];
y = [0.76897085, 0.8420684, 0];
z = [0.41040173, 0.5373925, 0];
StainVector=[x; y; z];
starts = zeros(3,3);
ends = StainVector';
q=quiver3(starts(:,1), starts(:,2), starts(:,3), ends(:,1), ends(:,2), ends(:,3),...
'Color', StainVector(:,1));
axis([0 1 0 1 0 1])
title('Test Plot')
xlabel('x')
ylabel('y')
zlabel('z')
这会产生一个带有两个矢量箭头的 3D 图(第三个被抑制,因为它开始和结束于 0,0,0。)如何将箭头的颜色更改为 RGB 值,以及颜色另一个箭头到另一个 RGB 值?
这是我从我的代码中得到的图像:
不幸的是,我只看到带有循环的选项,因为颜色选项应用于 quiver
调用中的所有箭头。
举个例子
colMap = eye(3); % RGB Matrix with your colors
for idx = 1:size(starts,1)
q=quiver3(starts(idx,1), starts(idx,2), starts(idx,3), ends(idx,1), ends(idx,2), ends(idx,3), ...
'Color', colMap(idx,:));
hold on
end
我在 Matlab 上有以下代码
x = [0.49015734, 0.04615336, 0];
y = [0.76897085, 0.8420684, 0];
z = [0.41040173, 0.5373925, 0];
StainVector=[x; y; z];
starts = zeros(3,3);
ends = StainVector';
q=quiver3(starts(:,1), starts(:,2), starts(:,3), ends(:,1), ends(:,2), ends(:,3),...
'Color', StainVector(:,1));
axis([0 1 0 1 0 1])
title('Test Plot')
xlabel('x')
ylabel('y')
zlabel('z')
这会产生一个带有两个矢量箭头的 3D 图(第三个被抑制,因为它开始和结束于 0,0,0。)如何将箭头的颜色更改为 RGB 值,以及颜色另一个箭头到另一个 RGB 值?
这是我从我的代码中得到的图像:
不幸的是,我只看到带有循环的选项,因为颜色选项应用于 quiver
调用中的所有箭头。
举个例子
colMap = eye(3); % RGB Matrix with your colors
for idx = 1:size(starts,1)
q=quiver3(starts(idx,1), starts(idx,2), starts(idx,3), ends(idx,1), ends(idx,2), ends(idx,3), ...
'Color', colMap(idx,:));
hold on
end