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:
legend with scatter points

Subject: legend with scatter points

From: J G

Date: 25 Mar, 2012 21:13:11

Message: 1 of 2

I have 5 points on a scatter graph (defined by a and b) which are different colors, specified by the bone colormap (this works fine). In the legend I want to define each of these colors. This is my code which doesn't work:

t = scatter(a,b,70,bone(5),'filled','MarkerEdgeColor', 'black')
u = legend(t([1 2 3 4 5]),{'0.1', '0.25', '0.5', '0.75', '0.9'}, 'Location', [0.6 0.45 0.2 0.2]);

I realise I could just plot the points individually and set each as t(1), t(2) etc but I was wondering if there was a way to avoid that? Thanks for any help!

Subject: legend with scatter points

From: J G

Date: 26 Mar, 2012 01:33:12

Message: 2 of 2

Nevermind, solved my problem using:

ch=get(t,'children');

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