<h3 dir="auto">Problem</h3>
<p dir="auto">Duplicate from <a href="https://stackoverflow.com/questions/72375427/matplotlib-plot-2d-data-in-3d-plot-as-a-projection-on-faces-without-the-2d-dots" rel="nofollow">stackoverflow 72375427</a> .</p>
<p dir="auto">When plotting 2D scatter data on a 3D scatter plot (eg as in the <a href="https://matplotlib.org/stable/gallery/mplot3d/2dcollections3d.html" rel="nofollow">example code from matplotlib website</a>, which incidentally shows the problematic behaviour as the sin curve is obviously off by a bit), the 2D data floats "on top" or "alongside" of the 2D face it is supposed to be placed upon and therefore gives the impression to be wrongly plotted. For example, using this to show the projection of dots from the 3D space to 2D planes (3 plot faces) gives the impression that the dots are not at the correct position, because of the parallax (see plot linked below).</p>
<p dir="auto"><a href="https://i.stack.imgur.com/yOkNr.png" rel="nofollow">3D plot with 2D plots on sides, as produced by above code</a><br>
<a href="https://i.stack.imgur.com/qDabq.png" rel="nofollow">3D plot with 2D plots on sides, as expected</a></p>
<p dir="auto">I cannot get the planes to exactly be positioned at a specified coordinate. Setting the x_lim, y_lim and z_lim parameters only slightly improves this, but there is still a slight, seemingly random, margin added beyond the axes limits (contrary to what happens in 2D plots).</p>
<h3 dir="auto">Proposed solution</h3>
<p dir="auto">I may have missed the option to do this. But it would be nice to have the possibility to overrule the automatic setting of the position of the edge planes so that setting the x_lim, y_lim and z_lim parameters fixes the planes to those specified values (for instance, or another extra parameter).</p>
<p dir="auto">Another solution based on generating the 2D graphs as images and adding them to the 3D plot could potentially work, but probably is a messy hack more than a solution.</p>
<p dir="auto">I take an example from<br>
<a href="https://stackoverflow.com/questions/23951230/python-axis-limit-in-matplotlib" rel="nofollow">https://stackoverflow.com/questions/23951230/python-axis-limit-in-matplotlib</a></p>
<p dir="auto">In mplot3d, when you set, for example, <code class="notranslate">set_xlim(0, 0.8)</code>, the outcome has an extra like <code class="notranslate">set_xlim(0 - eps, 0.8 + eps)</code>, where eps is related to <code class="notranslate">deltas</code>.<br>
</p><div class="Box Box--condensed my-2">
  <div class="Box-header f6">
    <p class="mb-0 text-bold">
      <a href="https://github.com/matplotlib/matplotlib/blob/6e76411a4f3e4cc54cae562529d8973fc12e4497/lib/mpl_toolkits/mplot3d/axis3d.py#L187">matplotlib/lib/mpl_toolkits/mplot3d/axis3d.py</a>
    </p>
    <p class="mb-0 color-fg-muted">
         Line 187
      in
      <a data-pjax="true" class="commit-tease-sha" href="/matplotlib/matplotlib/commit/6e76411a4f3e4cc54cae562529d8973fc12e4497">6e76411</a>
    </p>
  </div>
  <div itemprop="text" class="Box-body p-0 blob-wrapper blob-wrapper-embedded data">
    <table class="highlight tab-size mb-0 js-file-line-container" data-tab-size="8" data-paste-markdown-skip="">

        <tbody><tr class="border-0">
          <td id="L187" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="187"></td>
          <td id="LC187" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-s1">deltas</span> <span class="pl-c1">=</span> (<span class="pl-s1">maxs</span> <span class="pl-c1">-</span> <span class="pl-s1">mins</span>) <span class="pl-c1">/</span> <span class="pl-c1">12.</span> </td>
        </tr>
    </tbody></table>
  </div>
</div>
<p></p>
<p dir="auto">To show the exact lims, you have to change <code class="notranslate">deltas</code> to, for example, <code class="notranslate">0 * (maxs - mins) / 12.</code></p>
<p dir="auto">You need something to set exact lims without touching the inside of matplotlib.</p>
<p dir="auto"><strong>Code for reproduction</strong></p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.gca(projection = '3d')
ax.set_xlim(0,0.8)
plt.show()"><pre class="notranslate"><span class="pl-k">from</span> <span class="pl-s1">mpl_toolkits</span>.<span class="pl-s1">mplot3d</span> <span class="pl-k">import</span> <span class="pl-v">Axes3D</span>
<span class="pl-k">import</span> <span class="pl-s1">matplotlib</span>.<span class="pl-s1">pyplot</span> <span class="pl-k">as</span> <span class="pl-s1">plt</span>
<span class="pl-s1">fig</span> <span class="pl-c1">=</span> <span class="pl-s1">plt</span>.<span class="pl-en">figure</span>()
<span class="pl-s1">ax</span> <span class="pl-c1">=</span> <span class="pl-s1">fig</span>.<span class="pl-en">gca</span>(<span class="pl-s1">projection</span> <span class="pl-c1">=</span> <span class="pl-s">'3d'</span>)
<span class="pl-s1">ax</span>.<span class="pl-en">set_xlim</span>(<span class="pl-c1">0</span>,<span class="pl-c1">0.8</span>)
<span class="pl-s1">plt</span>.<span class="pl-en">show</span>()</pre></div>
<p dir="auto"><strong>Actual outcome</strong><br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/18307308/88422611-7f1de980-ce25-11ea-8125-9c795bd0b138.png"><img src="https://user-images.githubusercontent.com/18307308/88422611-7f1de980-ce25-11ea-8125-9c795bd0b138.png" alt="fig" style="max-width: 100%;"></a></p>
<p dir="auto"><strong>Matplotlib version</strong></p>
<ul dir="auto">
<li>Operating system:macOS 10.14.6</li>
<li>Matplotlib version: 3.1.1</li>
<li>Python version: 3.7.4</li>
</ul>
<p dir="auto">The problem was discussed many times in STACK OVERFLOW:<br>
<a href="https://stackoverflow.com/questions/23951230/python-axis-limit-in-matplotlib" rel="nofollow">https://stackoverflow.com/questions/23951230/python-axis-limit-in-matplotlib</a><br>
<a href="https://stackoverflow.com/questions/46380464/matplotlib-3d-axis-bounds-always-too-large-doesnt-set-lims-correctly" rel="nofollow">https://stackoverflow.com/questions/46380464/matplotlib-3d-axis-bounds-always-too-large-doesnt-set-lims-correctly</a><br>
<a href="https://stackoverflow.com/questions/16488182/removing-axes-margins-in-3d-plot" rel="nofollow">https://stackoverflow.com/questions/16488182/removing-axes-margins-in-3d-plot</a></p>