title: How to put legend outside the plotting area in Julia pyplot
body: <p>I am trying to find a way to put the Julia pyplot backend legend outside of the plotting area. I found some posts discussing this but I can't find a consistent answer. For example I find this post: <a href="https://discourse.julialang.org/t/location-of-the-legend-in-pyplot/1311" rel="nofollow noreferrer">https://discourse.julialang.org/t/location-of-the-legend-in-pyplot/1311</a> </p>
  
  <p>but the problem is that it seems axes() is no longer available in pyplot.</p>
  
  <p>P.S.  User ImportanceOfBeingErnest asked me to put the code. The following code is from post that I put the link to:</p>
  
  <pre><code>x = 0:0.1:3*pi
  y = sin(x)
  z = cos(x)
  ax = axes()
  plot(x,y,label="sin(x)")
  plot(x,z,label="cos(x)")
  grid("on")
  legend(bbox_to_anchor=[1.05,1],loc=2,borderaxespad=0)
  ax[:set_position]([0.06,0.06,0.71,0.91])
  </code></pre>
  
  <p>And the error I get:</p>
  
  <pre><code>MethodError: no method matching axes()
  Closest candidates are:
    axes(!Matched::Core.SimpleVector) at essentials.jl:593
    axes(!Matched::Core.SimpleVector, !Matched::Any) at essentials.jl:594
    axes(!Matched::Base.Generator) at generator.jl:52
    ...
  
  Stacktrace:
   [1] top-level scope at In[3]:7
  </code></pre>