Closed as not planned
Description
Bug report
Bug summary
A figure created with plot_directive
and preceeding label cannot be referenced with :ref:
or :numref:
.
Code for reproduction
.. _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`
Actual outcome
rendered HTML
LaTeX code
\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}}}
Expected outcome
The foo
references should be links like the bar
references.
Matplotlib version
- Operating system: Linux 4.10.0-35-generic 39~16.04.1-Ubuntu 16.04.3 LTS SMP x86_64 GNU/Linux
- Matplotlib version: 2.1.0 via pip
- Python version: 3.5.2
- Other libraries: Sphinx (sphinx-build) 1.6.4