title: Elegantly changing the color of a plot frame in matplotlib
body: <p>This is a kind of follow-up question to <a href="https://stackoverflow.com/questions/4761623/changing-the-color-of-the-axis-ticks-and-labels-for-a-plot-in-matplotlib">this</a> post, where the coloring of axes, ticks and labels was discussed. I hope it is alright to open a new, extended question for this.</p>
  
  <p>Changing the color of a complete frame (ticks and axes) around a double-plot (via <code>add_subplot</code>) with axes [ax1, ax2] results in a lot of code. This snippet changes the color of the frame <em>of the upper plot</em>:</p>
  
  <pre><code>ax1.spines['bottom'].set_color('green')
  ax1.spines['top'].set_color('green')
  ax1.spines['left'].set_color('green')
  ax1.spines['right'].set_color('green')
  for t in ax1.xaxis.get_ticklines(): t.set_color('green')
  for t in ax1.yaxis.get_ticklines(): t.set_color('green')
  for t in ax2.xaxis.get_ticklines(): t.set_color('green')
  for t in ax2.yaxis.get_ticklines(): t.set_color('green')
  </code></pre>
  
  <p>So for changing the frame color of two plots with two y-axes each, I would need 16(!) lines of code... This is how it looks like:</p>
  
  <p><img src="https://i.stack.imgur.com/TsgCB.png" alt="enter image description here"></p>
  
  <p>Other methods I dug up so far:</p>
  
  <ul>
  <li><p>matplotlib.rc: discussed <a href="https://stackoverflow.com/questions/1982770/matplotlib-changing-the-color-of-an-axis">here</a>; changes globally, not locally. I want to have some other plots in different colors. Please, no discussions about too many colors in plots... :-)</p>
  
  <pre><code>matplotlib.rc('axes',edgecolor='green')
  </code></pre></li>
  <li><p>dig out the spines of the axis, then change it: also discussed <a href="https://stackoverflow.com/questions/1982770/matplotlib-changing-the-color-of-an-axis">here</a>; not really elegant, I think.</p>
  
  <pre><code>for child in ax.get_children():
      if isinstance(child, matplotlib.spines.Spine):
          child.set_color('#dddddd')
  </code></pre></li>
  </ul>
  
  <blockquote>
    <p>Is there an <em>elegant</em> way of condensing the above block, something
    more "pythonic"?</p>
  </blockquote>
  
  <p>I'm using python 2.6.5 with matplotlib 0.99.1.1 under ubuntu.</p>