{"action":"created","issue":{"url":"https://api.github.com/repos/matplotlib/matplotlib/issues/9346","repository_url":"https://api.github.com/repos/matplotlib/matplotlib","labels_url":"https://api.github.com/repos/matplotlib/matplotlib/issues/9346/labels{/name}","comments_url":"https://api.github.com/repos/matplotlib/matplotlib/issues/9346/comments","events_url":"https://api.github.com/repos/matplotlib/matplotlib/issues/9346/events","html_url":"https://github.com/matplotlib/matplotlib/issues/9346","id":264302149,"number":9346,"title":"referencing a plot_directive plot does not work","user":{"login":"quantenschaum","id":3985599,"avatar_url":"https://avatars2.githubusercontent.com/u/3985599?v=4","gravatar_id":"","url":"https://api.github.com/users/quantenschaum","html_url":"https://github.com/quantenschaum","followers_url":"https://api.github.com/users/quantenschaum/followers","following_url":"https://api.github.com/users/quantenschaum/following{/other_user}","gists_url":"https://api.github.com/users/quantenschaum/gists{/gist_id}","starred_url":"https://api.github.com/users/quantenschaum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/quantenschaum/subscriptions","organizations_url":"https://api.github.com/users/quantenschaum/orgs","repos_url":"https://api.github.com/users/quantenschaum/repos","events_url":"https://api.github.com/users/quantenschaum/events{/privacy}","received_events_url":"https://api.github.com/users/quantenschaum/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2017-10-10T16:56:13Z","updated_at":"2017-10-10T18:27:30Z","closed_at":null,"author_association":"NONE","body":"<!--To help us understand and resolve your issue, please fill out the form to the best of your ability.-->\r\n<!--You can feel free to delete the sections that do not apply.-->\r\n\r\n### Bug report\r\n\r\n**Bug summary**\r\n\r\nA figure created with `plot_directive` and preceeding label cannot be referenced with `:ref:` or `:numref:`.\r\n\r\n**Code for reproduction**\r\n\r\n```rst\r\n.. _bar:\r\n\r\nTestplot\r\n--------\r\n\r\n.. _foo:\r\n\r\n.. plot::\r\n\r\n   import matplotlib.pyplot as plt\r\n   import numpy as np\r\n   plt.hist(np.random.randn(1000), 20)\r\n\r\nreference to plot: :ref:`foo` / :numref:`foo`\r\n\t\r\nreference to section: :ref:`bar` / :numref:`bar`\r\n```\r\n\r\n**Actual outcome**\r\n\r\nrendered HTML\r\n\r\n![bildschirmfoto_2017-10-10_18-42-44](https://user-images.githubusercontent.com/3985599/31398922-d75c4e24-adea-11e7-9347-cbec853efb33.png)\r\n\r\nLaTeX code\r\n\r\n```latex\r\n\\subsection{Testplot}\r\n\\label{\\detokenize{M01/index:testplot}}\\label{\\detokenize{M01/index:bar}}\\phantomsection\\label{\\detokenize{M01/index:foo}}\r\n\\begin{figure}[H]\r\n\\centering\r\n\r\n\\noindent\\sphinxincludegraphics{{index-1}.pdf}\r\n\\end{figure}\r\n\r\nreference to plot: \\DUrole{xref,std,std-ref}{foo} / \\sphinxcode{foo}\r\n\r\nreference to section: {\\hyperref[\\detokenize{M01/index:bar}]{\\sphinxcrossref{\\DUrole{std,std-ref}{Testplot}}}} / \\hyperref[\\detokenize{M01/index:bar}]{Section \\ref{\\detokenize{M01/index:bar}}}\r\n```\r\n\r\n**Expected outcome**\r\n\r\nThe `foo` references should be links like the `bar` references.\r\n\r\n**Matplotlib version**\r\n  * Operating system: Linux 4.10.0-35-generic 39~16.04.1-Ubuntu 16.04.3 LTS SMP x86_64 GNU/Linux\r\n  * Matplotlib version: 2.1.0 via pip\r\n  * Python version: 3.5.2\r\n  * Other libraries: Sphinx (sphinx-build) 1.6.4\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/matplotlib/matplotlib/issues/comments/335565074","html_url":"https://github.com/matplotlib/matplotlib/issues/9346#issuecomment-335565074","issue_url":"https://api.github.com/repos/matplotlib/matplotlib/issues/9346","id":335565074,"user":{"login":"quantenschaum","id":3985599,"avatar_url":"https://avatars2.githubusercontent.com/u/3985599?v=4","gravatar_id":"","url":"https://api.github.com/users/quantenschaum","html_url":"https://github.com/quantenschaum","followers_url":"https://api.github.com/users/quantenschaum/followers","following_url":"https://api.github.com/users/quantenschaum/following{/other_user}","gists_url":"https://api.github.com/users/quantenschaum/gists{/gist_id}","starred_url":"https://api.github.com/users/quantenschaum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/quantenschaum/subscriptions","organizations_url":"https://api.github.com/users/quantenschaum/orgs","repos_url":"https://api.github.com/users/quantenschaum/repos","events_url":"https://api.github.com/users/quantenschaum/events{/privacy}","received_events_url":"https://api.github.com/users/quantenschaum/received_events","type":"User","site_admin":false},"created_at":"2017-10-10T18:27:30Z","updated_at":"2017-10-10T18:27:30Z","author_association":"NONE","body":"1. The `plot` directive should support the [`:name:` option](http://docutils.sourceforge.net/docs/ref/rst/directives.html#name) to add a named label.\r\n2. Especially for inline plot code there should be a `:caption:` option"}}
{"actor":{"display_login":"quantenschaum"}}