<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import matplotlib.pyplot as plt

fig, (ax1, ax2) = plt.subplots(1, 2, True, False)
x1 = [1, 2, 3, 4, 5, 6, 7, 8, 9]
y1 = [x*x for x in x1]
ax1.plot(x1, y1)
x2=y2=[]
ax2.plot(x2, y2)
plt.show()"><pre class="notranslate"><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-s1">ax1</span>, <span class="pl-s1">ax2</span>) <span class="pl-c1">=</span> <span class="pl-s1">plt</span>.<span class="pl-en">subplots</span>(<span class="pl-c1">1</span>, <span class="pl-c1">2</span>, <span class="pl-c1">True</span>, <span class="pl-c1">False</span>)
<span class="pl-s1">x1</span> <span class="pl-c1">=</span> [<span class="pl-c1">1</span>, <span class="pl-c1">2</span>, <span class="pl-c1">3</span>, <span class="pl-c1">4</span>, <span class="pl-c1">5</span>, <span class="pl-c1">6</span>, <span class="pl-c1">7</span>, <span class="pl-c1">8</span>, <span class="pl-c1">9</span>]
<span class="pl-s1">y1</span> <span class="pl-c1">=</span> [<span class="pl-s1">x</span><span class="pl-c1">*</span><span class="pl-s1">x</span> <span class="pl-k">for</span> <span class="pl-s1">x</span> <span class="pl-c1">in</span> <span class="pl-s1">x1</span>]
<span class="pl-s1">ax1</span>.<span class="pl-en">plot</span>(<span class="pl-s1">x1</span>, <span class="pl-s1">y1</span>)
<span class="pl-s1">x2</span><span class="pl-c1">=</span><span class="pl-s1">y2</span><span class="pl-c1">=</span>[]
<span class="pl-s1">ax2</span>.<span class="pl-en">plot</span>(<span class="pl-s1">x2</span>, <span class="pl-s1">y2</span>)
<span class="pl-s1">plt</span>.<span class="pl-en">show</span>()</pre></div>
<p dir="auto">Now ax1.get_xlim() returns erroneous (-0.06, 0.06) because when bounding boxes of two plots are united, infinitely small bounding box of ax2 (Bbox('array([[ inf,  inf],\n       [-inf, -inf]])')) is considered infinitely large in transforms.BboxBase.union(). E. g. transforms.BboxBase.union([ax1.dataLim, ax2.dataLim]) returns Bbox('array([[-inf, -inf],\n       [ inf,  inf]])') which is incorrect.</p>
<p dir="auto">This bug prevents correct display of two plots with shared axis while one of them has empty data.</p>
<p dir="auto">Looks like I missed two points when reviewing <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/tacaswell/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/tacaswell">@tacaswell</a>'s parts of <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="323037208" data-permission-text="Title is private" data-url="https://github.com/matplotlib/matplotlib/issues/11246" data-hovercard-type="pull_request" data-hovercard-url="/matplotlib/matplotlib/pull/11246/hovercard" href="https://github.com/matplotlib/matplotlib/pull/11246">#11246</a>: <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="323037208" data-permission-text="Title is private" data-url="https://github.com/matplotlib/matplotlib/issues/11246" data-hovercard-type="pull_request" data-hovercard-url="/matplotlib/matplotlib/pull/11246/hovercard?comment_id=204527495&amp;comment_type=review" href="https://github.com/matplotlib/matplotlib/pull/11246#pullrequestreview-204527495">#11246 (review)</a> and <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="323037208" data-permission-text="Title is private" data-url="https://github.com/matplotlib/matplotlib/issues/11246" data-hovercard-type="pull_request" data-hovercard-url="/matplotlib/matplotlib/pull/11246/hovercard?comment_id=204536283&amp;comment_type=review" href="https://github.com/matplotlib/matplotlib/pull/11246#pullrequestreview-204536283">#11246 (review)</a>.</p>