Doug Grosser
Doug Grosser

Reputation: 41

Scatter plot with multiple markers

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?

Upvotes: 4

Views: 16410

Answers (3)

bla
bla

Reputation: 26069

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)

Upvotes: 7

Mario Barosso
Mario Barosso

Reputation: 1

The scattergroup property name is 'marker'

Check in doc 'Scattergroup Properties'

Upvotes: -2

user3437983
user3437983

Reputation: 21

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.

Upvotes: 2

Related Questions