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:
splitting 'legend' into 2 columns

Subject: splitting 'legend' into 2 columns

From: Srikanth Ramaswamy

Date: 2 Oct, 2007 17:16:47

Message: 1 of 3

Hi

I created a pie chart with about 100 sectors in it. I then used the 'legend'
function to create a legend for what each sector of the pie chart represents.
However, since I have about 100 entires in my pie chart, I'm unable to see the
entire contents of the legend table. Some of it is hidden due to the fact that
there are lots of entries to be displayed in the legend table.

I tried a few things like trying to create two legend tables, using something
like this:

h1 = legend(str(1;50), 'Location;, 'EastOutside');
h2 = legend(str(51:end), 'Location', 'WestOutside');

where str is a cell array

This obviously did not work. Did someone experience similar difficulties? Any
pointers or help would be most appreciated!

Cheers
Srikanth

Subject: splitting 'legend' into 2 columns

From: PB

Date: 2 Oct, 2007 17:51:31

Message: 2 of 3

Den Tue, 02 Oct 2007 17:16:47 +0000 skrev Srikanth Ramaswamy:

> Hi
>
> I created a pie chart with about 100 sectors in it. I then used the 'legend'
> function to create a legend for what each sector of the pie chart represents.
> However, since I have about 100 entires in my pie chart, I'm unable to see the
> entire contents of the legend table. Some of it is hidden due to the fact that
> there are lots of entries to be displayed in the legend table.
>
> I tried a few things like trying to create two legend tables, using something
> like this:
>
> h1 = legend(str(1;50), 'Location;, 'EastOutside');
> h2 = legend(str(51:end), 'Location', 'WestOutside');
>
> where str is a cell array
>
> This obviously did not work. Did someone experience similar difficulties? Any
> pointers or help would be most appreciated!
>
> Cheers
> Srikanth

This might help

http://groups.google.com/group/comp.soft-sys.matlab/browse_thread/thread/a19e615f1646cc48/bf1bfd2152dff6f0?lnk=gst&q=Long+Horizontal+Wrapped+Legend&rnum=1#bf1bfd2152dff6f0

/PB

Subject: splitting 'legend' into 2 columns

From: Luciana Vieira

Date: 23 Apr, 2009 17:42:02

Message: 3 of 3

"Srikanth Ramaswamy" <srikanth.ramaswamy.NOSPAM@gmail.com> wrote in message <fdtudv$5qm$1@fred.mathworks.com>...
> Hi
>
> I created a pie chart with about 100 sectors in it. I then used the 'legend'
> function to create a legend for what each sector of the pie chart represents.
> However, since I have about 100 entires in my pie chart, I'm unable to see the
> entire contents of the legend table. Some of it is hidden due to the fact that
> there are lots of entries to be displayed in the legend table.
>
> I tried a few things like trying to create two legend tables, using something
> like this:
>
> h1 = legend(str(1;50), 'Location;, 'EastOutside');
> h2 = legend(str(51:end), 'Location', 'WestOutside');
>
> where str is a cell array
>
> This obviously did not work. Did someone experience similar difficulties? Any
> pointers or help would be most appreciated!
>
> Cheers
> Srikanth
>
>
Hi,

In the last days I had searching for a solution for a problem like that. I found an interesting solution, simple and efficient. Look at:

http://www.mathworks.com/matlabcentral/newsreader/view_thread/165967

My review of that solution is:

% mathematical functions
x = 1:10;
y1 = x;
y2 = 2*x;
y3 = x+4;
y4 = 0.5*x-2;
y5 = x-4;
y6 = x/3;

% graphics
h(1)=plot(x,y1,'b'); hold on;
h(2)=plot(x,y2,'r');
h(3)=plot(x,y3,'k');
h(4)=plot(x,y4,'g');
h(5)=plot(x,y5,'m');
h(6)=plot(x,y6,'y');

% Plotting 3 legend blocks:

% Block 1
% Axes handle 1 (this is the visible axes)
ah1 = gca;
% Legend at axes 1
legend(ah1,h(1:2),'y1','y2',1)

% Block 2
% Axes handle 2 (unvisible, only for place the second legend)
ah2=axes('position',get(gca,'position'), 'visible','off');
% Legend at axes 2
legend(ah2,h(3:4),'y3','y4',2)

% Block 3
% Axes handle 3 (unvisible, only for place the third legend)
ah3=axes('position',get(gca,'position'), 'visible','off');
% Legend at axes 3
legend(ah3,h(5:6),'y5','y6',3)

Tags for 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