Scatter plot with multiple markers

Doug Grosser picture Doug Grosser · Jan 8, 2013 · Viewed 15.7k times · Source

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.

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?

Answer

bla picture bla · Jan 8, 2013

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

enter image description here

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

  • '+' 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)