4

我正在尝试将来自多个数据文件的散点图放在一起,以查看它们之间的相关性。代码如下所示:

hold all
fia = fopen('data.txt');
A = fscanf(fia, '%f %f %f', [3 inf]);
t = A(1,:);
a = A(2,:);
r = A(3,:);

figure(1)
scatter(log(r),log(a),'r', '-');

fclose(fia);

fia = fopen('data.txt');
A = fscanf(fia, '%f %f %f', [3 inf]);
t = A(1,:);
a = A(2,:);
r = A(3,:);

figure(2);
scatter(log(r),log(a), 'g', '-');

fclose(fia);

依此类推,下一个数据点绘制在同一张图上:

fia = fopen('data.txt');
A = fscanf(fia, '%f %f %f', [3 inf]);
t = A(1,:);
a = A(2,:);
r = A(3,:);

figure(1);
scatter(log(r),log(a), 'rx');


fclose(fia);

等等。

但是当我在 Matlab 中运行该函数时,我得到了这个错误:

Error using specgraph.scattergroup/set
The name 'linestyle' is not an accessible property for an instance
of class 'scattergroup'.

Error in specgraph.scattergroup (line 26)
  set(h,args{:});

Error in scatter (line 83)
        h = specgraph.scattergroup('parent',parax,'cdata',c,...

Error in Ratioincrease (line 11)
scatter(log(r),log(a),'r', '-');

我怎样才能让 scattergroup 类似于线组,就像我如何正确编写它一样?

4

3 回答 3

7

scatter使用和显示不同的标记应该没有问题。例如:

load seamount
scatter(x,y,30,z,'s'); hold on
scatter(.999*x,1.001*y,30,z,'x'); hold on
scatter(1.001*x,.999*y,30,z,'+'); hold on

在此处输入图像描述

我怀疑您有错字并用作-标记类型。您可以使用的标记类型是:

  • '+' 加号
  • 'o' 圆圈
  • '*' 星号
  • '.' 观点
  • 'x'
  • 'square''s' 正方形
  • 'diamond''d'钻石
  • '^' 向上的三角形
  • 'v' 向下三角形
  • '>' 指向右边的三角形
  • '<' 向左三角形
  • 'pentagram''p'五角星(五角星)
  • 'hexagram''h' 六角星(六角星)
于 2013-01-08T08:11:40.543 回答
2

Just to add that you don't have to write 'hold on' for each line. Once will be sufficient. So, for this you can write:

load seamount
scatter(x,y,30,z,'s'); hold on
scatter(.999*x,1.001*y,30,z,'x'); 
scatter(1.001*x,.999*y,30,z,'+'); 

Also, if you wanna draw a new set of data and clean the previous, you need to write 'hold off' once before doing this command.

于 2014-05-11T10:31:12.847 回答
-2

scattergroup 属性名称是 'marker'

签入文档'Scattergroup Properties'

于 2015-04-16T10:52:19.997 回答