如何在散点图中包含超过10种标记类型?

时间:2015-12-22 12:38:47

标签: matlab plot scatter-plot

文档在散点图中仅指定了10种类型的标记: http://uk.mathworks.com/help/matlab/ref/scatter.html

我需要30.标记类型的当前字符串是:

markers = '+o*.xsd^v<>h';

我不想重复使用相同的标记。输入其他字母等会导致崩溃。字母表中的字母是可接受的标记。有没有办法有超过10种标记?

编辑:我已经使用颜色来表示其他内容了。

2 个答案:

答案 0 :(得分:2)

可以使用多个函数来模拟scatter的行为。在这里,我们使用textplot来创建唯一标记。

在左侧,带有数字和点的标记,在右侧圆圈和箭头上(由于unicode)。

enter image description here

计算:

N = 50;
x = rand(N,1);
y = rand(N,1);

%numbers in text
txt1 = cellstr(num2str((11:11+N-1)'));

%unicode text
Nstart = 8592; %arrows 
txt2 = cellstr(char(Nstart:Nstart+N-1)');

figure;
subplot(1,2,1);
h = text(x, y, txt1, ...
    'FontName', 'Courier New', 'FontSize', 18, ...
    'HorizontalAlignment', 'center', 'VerticalAlignment', 'middle');

hold on;
plot(x, y, 'r.', 'MarkerSize', 10)

subplot(1,2,2);
h = text(x, y, txt2, ...
    'FontSize', 20, ...
    'HorizontalAlignment', 'center', 'VerticalAlignment', 'middle');

hold on;
plot(x, y, 'o', 'MarkerSize', 22)

答案 1 :(得分:1)

您可以使用text在特定位置绘制字母。效率会低得多,因为每个点都需要一个新的图形对象。