<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p>Ok Ben,</p>
    <p>I tried the following per your suggestion:</p>
    <p> <tt> fig, axarr = plt.subplots(NSub, figsize=(width,height),
        squeeze=False, sharex=True)</tt></p>
    <p>but when the following is executed:</p>
    <p><tt>  ax.grid(True) <br>
      </tt></p>
    <p>I get the following error message:<tt>  </tt><br>
      <tt><span style=" font-size:large; font-weight:600;
          color:#000066;">  builtins.AttributeError: 'numpy.ndarray'
          object has no attribute 'grid'</span></tt></p>
    <p>But, thanks for your help <span class="moz-smiley-s1"><span>:-)</span></span>.<tt><br>
      </tt></p>
    <br>
    <div class="moz-cite-prefix">On 2018-04-17 16:30, Benjamin Root
      wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CANNq6F=5r+nQwZoOgHuds7DSn0aWgsEtyvvoqLz=PYihiT13hA@mail.gmail.com">
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
      <div dir="ltr">
        <div>
          <div>By default, `squeeze` is called on the array prior to
            returning it. This way, users don't need to deal with 2D
            arrays when most of the time, they are dealing with 1D
            setups. You can specify squeeze=False to subplots to turn
            this behavior off and always have a 2D array.<br>
            <br>
          </div>
          I hope that helps!<br>
        </div>
        Ben Root<br>
        <br>
        <div class="gmail_extra"><br>
          <div class="gmail_quote">On Tue, Apr 17, 2018 at 10:12 AM,
            Virgil Stokes <span dir="ltr"><<a
                href="mailto:vs@it.uu.se" target="_blank"
                moz-do-not-send="true">vs@it.uu.se</a>></span> wrote:<br>
            <blockquote class="gmail_quote" style="margin:0 0 0
              .8ex;border-left:1px #ccc solid;padding-left:1ex">
              <div text="#000000" bgcolor="#FFFFFF"> The following line
                is part of a much larger python (3.6) with Matplotlib
                (2.2.2) program in which the number of subplots is
                determined from input data: <br>
                <br>
                  <tt>fig, axarr = plt.subplots(NSub,
                  figsize=(width,height), sharex=True) </tt><br>
                <br>
                This works fine when the number of subplots (NSub) is
                greater than 1. For example when NSub=3, axarr is an
                array of length 3 and contains: <br>
                <br>
                 <tt> array([<matplotlib.axes._subpl<wbr>ots.AxesSubplot
                  object at 0x0000025900E9DDD8>, </tt><tt><br>
                </tt><tt>         <matplotlib.axes._subplots.Axe<wbr>sSubplot
                  object at 0x00000259011897F0>, </tt><tt><br>
                </tt><tt>         <matplotlib.axes._subplots.Axe<wbr>sSubplot
                  object at 0x00000259011C7128>], </tt><tt><br>
                </tt><tt>        dtype=object) </tt><br>
                <br>
                However, when NSub=1, axarr contains: <br>
                <br>
                  <tt><matplotlib.axes._subplots.Axe<wbr>sSubplot
                  object at 0x00000161AB26AE80> <br>
                  <br>
                  and of course, will give an error if axarr is an
                  array; i.e.<br>
                  <br>
                    </tt><tt><span
                    style="font-size:large;font-weight:600;color:#000066">builtins.TypeError:
                    'AxesSubplot' object does not support indexing</span>
                </tt><br>
                <br>
                For my code this requires special handling because axarr
                is no longer an array. Why not have axarr contain: <br>
                <br>
                 <tt> array([<matplotlib.axes._subpl<wbr>ots.AxesSubplot
                  object at 0x00000161AB26AE80>],dtype=obj<wbr>ect) </tt><br>
                <br>
                when NSub=1. IMHO this is consistent; i.e. it is an
                array with a length that is equal to the number of
                subplots. </div>
              <br>
              ______________________________<wbr>_________________<br>
              Matplotlib-users mailing list<br>
              <a href="mailto:Matplotlib-users@python.org"
                target="_blank" moz-do-not-send="true">Matplotlib-users@python.org</a><br>
              <a
                href="https://mail.python.org/mailman/listinfo/matplotlib-users"
                rel="noreferrer" target="_blank" moz-do-not-send="true">https://mail.python.org/mailma<wbr>n/listinfo/matplotlib-users</a><br>
              <br>
            </blockquote>
          </div>
          <br>
        </div>
      </div>
    </blockquote>
    <br>
  </body>
</html>