Path: news.mathworks.com!not-for-mail
From: "Jerry" <mricad@yahoo.no000spppam.com>
Newsgroups: comp.soft-sys.matlab
Subject: reorder legend items
Date: Sat, 1 Nov 2008 03:34:02 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 7
Message-ID: <gegina$eds$1@fred.mathworks.com>
Reply-To: "Jerry" <mricad@yahoo.no000spppam.com>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1225510442 14780 172.30.248.37 (1 Nov 2008 03:34:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sat, 1 Nov 2008 03:34:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 544673
Xref: news.mathworks.com comp.soft-sys.matlab:498379


figure;
plot(0:10,0:10,'rx-',0:10,10:-1:0,'go--');
legend('cross','circle');

the order of the legend items depends on the oder of plotting, i.e., in the example above, it will be "rx- cross" on the top. Is there any way to switch the order without re-plot? switching the string is not hard, but I didn't figure out how to switch the whole thing, e.g., make "go-- circle" on the top. This is useful, for example, after you create a figure with a legend of many items, then for some reason, you want to change the order of the legend. (the order of plotting may be ad hoc, but you want your legend follow some rule). 

Thanks.