<p dir="auto">To help us understand and resolve your issue please check that you have provided<br>
the information below.</p>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> Matplotlib version, Python version and Platform (Windows, OSX, Linux ...)</li>
</ul>
<blockquote>
<p dir="auto">1.5.2rc2, python 2.7.11 and python 3.5.1, Fedora rawhide.</p>
</blockquote>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> How did you install Matplotlib and Python (pip, anaconda, from source ...)</li>
</ul>
<blockquote>
<p dir="auto">From source, I'm building a new version of the Fedora package.</p>
</blockquote>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> If possible please supply a <a href="http://sscce.org/" rel="nofollow">Short, Self Contained, Correct, Example</a><br>
that demonstrates the issue i.e a small piece of code which reproduces the issue<br>
and can be run with out any other (or as few as possible) external dependencies.</li>
</ul>
<blockquote>
<p dir="auto">In Fedora, we're patching the <code class="notranslate">lib/matplotlib/__init__.py</code> to use <code class="notranslate">/usr/share/matplotlib/mpl-data</code> as the path for data files. <code class="notranslate">cbook.py</code> seems to have its own reimplementation of the data files path code, so the path needs to be patched in two locations. It would be nice if we could specify the desired data files location path at build time, by the way. Shall I open a separate issue for that?</p>
</blockquote>
<p dir="auto">Trivial patch:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="--- a/lib/matplotlib/cbook.py   2016-05-20 14:14:52.000000000 +0200
+++ b/lib/matplotlib/cbook.py   2016-05-20 19:28:57.373601582 +0200
@@ -823,8 +823,7 @@ def get_sample_data(fname, asfileobj=Tru
     if matplotlib.rcParams['examples.directory']:
         root = matplotlib.rcParams['examples.directory']
     else:
-        root = os.path.join(os.path.dirname(__file__),
-                            &quot;mpl-data&quot;, &quot;sample_data&quot;)
+        root = os.path.join(matplotlib._get_data_path(), 'sample_data')
     path = os.path.join(root, fname)

     if asfileobj:"><pre class="notranslate"><code class="notranslate">--- a/lib/matplotlib/cbook.py   2016-05-20 14:14:52.000000000 +0200
+++ b/lib/matplotlib/cbook.py   2016-05-20 19:28:57.373601582 +0200
@@ -823,8 +823,7 @@ def get_sample_data(fname, asfileobj=Tru
     if matplotlib.rcParams['examples.directory']:
         root = matplotlib.rcParams['examples.directory']
     else:
-        root = os.path.join(os.path.dirname(__file__),
-                            "mpl-data", "sample_data")
+        root = os.path.join(matplotlib._get_data_path(), 'sample_data')
     path = os.path.join(root, fname)

     if asfileobj:
</code></pre></div>
<p dir="auto">The documentation pages at <a href="https://matplotlib.org/gallery/axes_grid1/simple_anchored_artists.html" rel="nofollow">https://matplotlib.org/gallery/axes_grid1/simple_anchored_artists.html</a> and <a href="https://matplotlib.org/gallery/misc/anchored_artists.html" rel="nofollow">https://matplotlib.org/gallery/misc/anchored_artists.html</a> appear to be nearly duplicates of each other. However, the first one is much more complete, and demonstrates a much less complicated way of achieving he same thing.</p>
<p dir="auto">The first linked page has a <code class="notranslate">if 1:</code> "guard" while the second one has <code class="notranslate">if __name__ == '__main__':</code>. Given the overall trend in the examples, neither seems necessary.</p>
<p dir="auto">An even simpler example, that is fully covered by the other ones, is given in <a href="https://matplotlib.org/gallery/userdemo/anchored_box01.html" rel="nofollow">https://matplotlib.org/gallery/userdemo/anchored_box01.html</a></p>
<p dir="auto">My personal take on this is:</p>
<ul dir="auto">
<li>Keep the content of <a href="https://matplotlib.org/gallery/axes_grid1/simple_anchored_artists.html" rel="nofollow">https://matplotlib.org/gallery/axes_grid1/simple_anchored_artists.html</a>. The other version asks the user to write their own version of the anchored artist classes, even though matplotlib already provides them, and is generally less complete.</li>
<li>Move it to <a href="https://matplotlib.org/gallery/misc/anchored_artists.html" rel="nofollow">https://matplotlib.org/gallery/misc/anchored_artists.html</a> since it has nothing to do with axis grids and I'm not even sure how it ended up there.</li>
<li>Removing the unnecessary import guard.</li>
<li>Remove <a href="https://matplotlib.org/gallery/userdemo/anchored_box01.html" rel="nofollow">https://matplotlib.org/gallery/userdemo/anchored_box01.html</a> entirely.</li>
</ul>
<p dir="auto">I'll be happy to submit a PR if a couple of senior folks approve.</p>
<p dir="auto">P.S. The reason for all this is in the comment section of <a href="https://stackoverflow.com/a/49933937/2988730" rel="nofollow">https://stackoverflow.com/a/49933937/2988730</a>, when I realized I was giving somebody incomplete, or possibly outright bad advice.</p>