具有多个标记的散点图 [英] Scatter plot with multiple markers

查看:129
本文介绍了具有多个标记的散点图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将多个数据文件中的散点图放在一起,以查看它们之间的相互关系.代码如下:

I am trying to put a scatter plot together from multiple data files, to see how the correlate to each other. The code looks like this:

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);

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

And so on, where the next data points are plotted on the same graph:

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);

ect.

但是当我在Matlab中运行该函数时,出现此错误:

But when I run the function in Matlab, I get this error:

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', '-');

如何使散点组类似于线路组,如我如何正确地编写它?

How can I have the scattergroup similar to a line group, as in how do I write it properly?

推荐答案

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

There shouldn't be a problem to use scatter and show different markers. For example:

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

我怀疑您输入错误,并使用-作为标记类型.您可以使用的标记类型为:

I suspect that you had a typo and used - as a marker type. The marker types you can use are :

  • '+'加号
  • 'o'圈子
  • '*'星号
  • '.'
  • 'x'十字架
  • 'square''s'正方形
  • 'diamond''d'钻石
  • '^'朝上三角形
  • 'v'指向下的三角形
  • '>'右指向三角形
  • '<'左指向三角形
  • 'pentagram''p'五角星(五角星)
  • 'hexagram''h'六角星(六边形)
  • '+' Plus sign
  • 'o' Circle
  • '*' Asterisk
  • '.' Point
  • 'x' Cross
  • 'square' or 's' Square
  • 'diamond' or 'd' Diamond
  • '^' Upward-pointing triangle
  • 'v' Downward-pointing triangle
  • '>' Right-pointing triangle
  • '<' Left-pointing triangle
  • 'pentagram' or 'p' Five-pointed star (pentagram)
  • 'hexagram' or 'h' Six-pointed star (hexagram)

这篇关于具有多个标记的散点图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆