<p dir="auto">Plotting a numpy matrix in matplotlib 1.3.1 breaks, with the exception:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&gt;&gt;&gt; plot(matrix([[1,2,3]]))
  File &quot;/usr/local/lib/python2.7/dist-packages/matplotlib/units.py&quot;, line 148, in get_converter
    converter = self.get_converter(xravel[0])
  File &quot;/usr/local/lib/python2.7/dist-packages/numpy/matrixlib/defmatrix.py&quot;, line 316, in __getitem__
    out = N.ndarray.__getitem__(self, index)
RuntimeError: maximum recursion depth exceeded"><pre class="notranslate"><code class="notranslate">&gt;&gt;&gt; plot(matrix([[1,2,3]]))
  File "/usr/local/lib/python2.7/dist-packages/matplotlib/units.py", line 148, in get_converter
    converter = self.get_converter(xravel[0])
  File "/usr/local/lib/python2.7/dist-packages/numpy/matrixlib/defmatrix.py", line 316, in __getitem__
    out = N.ndarray.__getitem__(self, index)
RuntimeError: maximum recursion depth exceeded
</code></pre></div>
<p dir="auto">On matplotlib 1.1.1 plots three lines, as expected.  Reproduced on:</p>
<ul dir="auto">
<li>python 2.7.3, linux, numpy 1.8.0</li>
<li>python 2.7.5, windows,  numpy 1.7.1</li>
</ul>
<h3 dir="auto">Bug report</h3>
<p dir="auto"><strong>Bug summary</strong></p>
<p dir="auto">A figure created with <code class="notranslate">plot_directive</code> and preceeding label cannot be referenced with <code class="notranslate">:ref:</code> or <code class="notranslate">:numref:</code>.</p>
<p dir="auto"><strong>Code for reproduction</strong></p>
<div class="highlight highlight-text-restructuredtext notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content=".. _bar:

Testplot
--------

.. _foo:

.. plot::

   import matplotlib.pyplot as plt
   import numpy as np
   plt.hist(np.random.randn(1000), 20)

reference to plot: :ref:`foo` / :numref:`foo`
	
reference to section: :ref:`bar` / :numref:`bar`"><pre class="notranslate">.. _<span class="pl-en">bar</span>:

Testplot
<span class="pl-mh">--------</span>

.. _<span class="pl-en">foo</span>:

.. <span class="pl-c1">plot</span>::

   import matplotlib.pyplot as plt
   import numpy as np
   plt.hist(np.random.randn(1000), 20)

reference to plot: <span class="pl-k">:ref:</span>`<span class="pl-corl">foo</span>` / <span class="pl-k">:numref:</span>`<span class="pl-corl">foo</span>`
	
reference to section: <span class="pl-k">:ref:</span>`<span class="pl-corl">bar</span>` / <span class="pl-k">:numref:</span>`<span class="pl-corl">bar</span>`</pre></div>
<p dir="auto"><strong>Actual outcome</strong></p>
<p dir="auto">rendered HTML</p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/3985599/31398922-d75c4e24-adea-11e7-9347-cbec853efb33.png"><img src="https://user-images.githubusercontent.com/3985599/31398922-d75c4e24-adea-11e7-9347-cbec853efb33.png" alt="bildschirmfoto_2017-10-10_18-42-44" style="max-width: 100%;"></a></p>
<p dir="auto">LaTeX code</p>
<div class="highlight highlight-text-tex-latex notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="\subsection{Testplot}
\label{\detokenize{M01/index:testplot}}\label{\detokenize{M01/index:bar}}\phantomsection\label{\detokenize{M01/index:foo}}
\begin{figure}[H]
\centering

\noindent\sphinxincludegraphics{{index-1}.pdf}
\end{figure}

reference to plot: \DUrole{xref,std,std-ref}{foo} / \sphinxcode{foo}

reference to section: {\hyperref[\detokenize{M01/index:bar}]{\sphinxcrossref{\DUrole{std,std-ref}{Testplot}}}} / \hyperref[\detokenize{M01/index:bar}]{Section \ref{\detokenize{M01/index:bar}}}"><pre class="notranslate"><span class="pl-c1">\subsection</span>{<span class="pl-en">Testplot</span>}
<span class="pl-k">\label</span>{\<span class="pl-v">detokenize</span>{<span class="pl-v">M01/index:testplot</span>}}<span class="pl-k">\label</span>{\<span class="pl-v">detokenize</span>{<span class="pl-v">M01/index:bar</span>}}<span class="pl-c1">\phantomsection</span><span class="pl-k">\label</span>{\<span class="pl-v">detokenize</span>{<span class="pl-v">M01/index:foo</span>}}
<span class="pl-c1">\begin</span>{<span class="pl-smi">figure</span>}[H]
<span class="pl-c1">\centering</span>

<span class="pl-c1">\noindent\sphinxincludegraphics</span>{{index-1}.pdf}
<span class="pl-c1">\end</span>{<span class="pl-smi">figure</span>}

reference to plot: <span class="pl-c1">\DUrole</span>{xref,std,std-ref}{foo} / <span class="pl-c1">\sphinxcode</span>{foo}

reference to section: {<span class="pl-c1">\hyperref</span>[<span class="pl-c1">\detokenize</span>{M01/index:bar}]{<span class="pl-k">\sphinxcrossref</span>{\<span class="pl-c1">DUrole</span>{<span class="pl-c1">std,std-ref</span>}{Testplot}}}} / <span class="pl-c1">\hyperref</span>[<span class="pl-c1">\detokenize</span>{M01/index:bar}]{Section <span class="pl-k">\ref</span>{\<span class="pl-c1">detokenize</span>{<span class="pl-c1">M01/index:bar</span>}}}</pre></div>
<p dir="auto"><strong>Expected outcome</strong></p>
<p dir="auto">The <code class="notranslate">foo</code> references should be links like the <code class="notranslate">bar</code> references.</p>
<p dir="auto"><strong>Matplotlib version</strong></p>
<ul dir="auto">
<li>Operating system: Linux 4.10.0-35-generic 39~16.04.1-Ubuntu 16.04.3 LTS SMP x86_64 GNU/Linux</li>
<li>Matplotlib version: 2.1.0 via pip</li>
<li>Python version: 3.5.2</li>
<li>Other libraries: Sphinx (sphinx-build) 1.6.4</li>
</ul>