简体   繁体   English

在3D干图Matlab中用颜色区分数据点

[英]Differentiate data points with color in a 3D stem plot Matlab

Say I have a matrix (named as data) with multiple rows and columns. 假设我有一个包含多行和多列的矩阵(称为数据)。 I am plotting using stem3 to get a 3D view. 我正在使用stem3进行绘图以获取3D视图。

    col1 col2 col3
row1
row2
row3
...

col1 and col2 are used as x and y axes. col1和col2用作x和y轴。 col3 is used as z axis. col3用作z轴。

stem3(data(:,1),data(:,2),data(:,3),'red')

在此处输入图片说明

Is there a way that I can manipulate the color of those data points, in which the data points with value greater than the height 500 are blue, while the rest remain red? 有没有一种方法可以操纵那些数据点的颜色,其中值大于高度500的数据点为蓝色,而其余的保持红色? Thanks for your help! 谢谢你的帮助!

The easiest thing is going to be to simply create two different stem3 plots. 最简单的方法是简单地创建两个不同的stem3图。 You will create one that only shows the values that are greater than your cutoff (500) and make it blue. 您将创建一个仅显示大于临界值(500)的值,然后将其设置为蓝色。 Then you'll create one that is all the others using red markers. 然后,您将创建一个使用红色标记的所有其他标记。

% Logical array to determine which population each point belongs to
isAbove = data(:,3) > 500;

stem3(data(isAbove,1), data(isAbove,2), data(isAbove,3), 'b');

hold on

stem3(data(~isAbove,1), data(~isAbove,2), data(~isAbove,3), 'r');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM