Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

splitting 'legend' into 2 columns

188 views
Skip to first unread message

Srikanth Ramaswamy

unread,
Oct 2, 2007, 1:15:32 PM10/2/07
to
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


Srikanth Ramaswamy

unread,
Oct 2, 2007, 1:16:47 PM10/2/07
to

PB

unread,
Oct 2, 2007, 1:51:31 PM10/2/07
to

Luciana Vieira

unread,
Apr 23, 2009, 1:42:02 PM4/23/09
to
"Srikanth Ramaswamy" <srikanth.ram...@gmail.com> wrote in message <fdtudv$5qm$1...@fred.mathworks.com>...
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)

0 new messages