Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!news2.google.com!npeer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post01.iad.highwinds-media.com!newsfe11.iad.POSTED!7564ea0f!not-for-mail
From: Walter Roberson <roberson@hushmail.com>
User-Agent: Thunderbird 2.0.0.24 (Macintosh/20100228)
MIME-Version: 1.0
Newsgroups: comp.soft-sys.matlab
Subject: Re: How to add legend to an area plot with line plot overlay
References: <hsneb1$7s0$1@fred.mathworks.com>
In-Reply-To: <hsneb1$7s0$1@fred.mathworks.com>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 14
Message-ID: <47IHn.10680$wV.1561@newsfe11.iad>
NNTP-Posting-Host: 24.79.143.47
X-Complaints-To: internet.abuse@sjrb.ca
X-Trace: newsfe11.iad 1273974336 24.79.143.47 (Sun, 16 May 2010 01:45:36 UTC)
NNTP-Posting-Date: Sun, 16 May 2010 01:45:36 UTC
Date: Sat, 15 May 2010 20:45:35 -0500
Xref: news.mathworks.com comp.soft-sys.matlab:636186

Patrick Xu wrote:
> Hi, I am trying to create a plot with an area plot and a line plot (on 
> the second axis). My question is how do you add a legend for both plots. 

When you call legend() you can specify objects whose legend is to be 
included. The legend will be positioned on the axis(es) for those 
objects, according to the parameters you specify. You would want 
different positions for the two different axes. There is no direct way 
to specify that you would like one legend to be "underneath" or "beside" 
another, but if you were to position one first then you might be able to 
  get() the legend position and work out the position from there. If I 
recall correctly, each legend box is placed on a new axis, so a figure 
that had two plots on different axis, and distinct legends for each, 
would involve a total of four axes.