Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
gscatter multiple groups

Subject: gscatter multiple groups

From: Katia

Date: 22 Oct, 2013 17:30:08

Message: 1 of 2

Hi,

My question seems rather simple, but I haven't been able to find an answer online.

I am using gscatter to plot variables color coded by group. Synthetic example below:

X=randn(10,1);
Y=randn(10,1);
grp1=[1 1 1 2 2 3 4 4 4 4];
grp2=[19 31 48 34 36 27 22 27 33 21];

gscatter(X,Y,grp1) or gscatter(X,Y,grp2) works well.

But what I really wanted was to have the scatter plot color coded by group 2 and marker coded by group 1.
I found an image online to exemplify (generally) what I am trying to accomplish.

http://tulip.labri.fr/TulipDrupal/?q=node/341

Thank you,
Kátia

Subject: gscatter multiple groups

From: Tom Lane

Date: 22 Oct, 2013 21:14:34

Message: 2 of 2

> But what I really wanted was to have the scatter plot color coded by group
> 2 and marker coded by group 1.

Ktia, maybe you can modify this to get what you want:

x = (1:12)'; y = x.^2;
g1 = [1 2 3 1 2 3 1 2 3 1 2 3]';
g2 = [1 1 1 2 2 2 1 1 1 2 2 2]';
gscatter(x,y,{g2 g1},repmat(eye(3),2,1),'xxxsss')

The idea is to provide the same color for each group with a common g1, and
the same marker for each group with a common g2. I found I had to specify
the groups controlling the maker first to get what I want.

-- Tom

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us