<h3 dir="auto">Bug summary</h3>
<p dir="auto">I put a <code class="notranslate">torch.Tensor</code> in <code class="notranslate">matplotlib.pyplot.hist()</code> ,  but it draw a wrong graphic and take a long time.<br>
Although transform to numpy, the function work well. But all the others function I used are work well on tensor. So I think its a bug.</p>
<h3 dir="auto">Code for reproduction</h3>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import matplotlib.pyplot as plt
import torch

plt.hist(torch.randn(20))
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-k">import</span> <span class="pl-s1">torch</span>

<span class="pl-s1">plt</span>.<span class="pl-en">hist</span>(<span class="pl-s1">torch</span>.<span class="pl-en">randn</span>(<span class="pl-c1">20</span>))
<span class="pl-s1">plt</span>.<span class="pl-en">show</span>()</pre></div>
<h3 dir="auto">Actual outcome</h3>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/45221786/184349059-7aca87cb-6a5a-4b89-9d0b-207c8604e45e.png"><img src="https://user-images.githubusercontent.com/45221786/184349059-7aca87cb-6a5a-4b89-9d0b-207c8604e45e.png" alt="image" style="max-width: 100%;"></a></p>
<h3 dir="auto">Expected outcome</h3>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/45221786/184349216-c6ed46e2-bfb3-4bd6-b03e-4fb6120a1686.png"><img src="https://user-images.githubusercontent.com/45221786/184349216-c6ed46e2-bfb3-4bd6-b03e-4fb6120a1686.png" alt="image" style="max-width: 100%;"></a></p>
<h3 dir="auto">Additional information</h3>
<p dir="auto"><em>No response</em></p>
<h3 dir="auto">Operating system</h3>
<p dir="auto">Windows</p>
<h3 dir="auto">Matplotlib Version</h3>
<p dir="auto">3.5.1</p>
<h3 dir="auto">Matplotlib Backend</h3>
<p dir="auto">module://ipykernel.pylab.backend_inline</p>
<h3 dir="auto">Python version</h3>
<p dir="auto">3.7.13</p>
<h3 dir="auto">Jupyter version</h3>
<p dir="auto">6.4.8</p>
<h3 dir="auto">Installation</h3>
<p dir="auto">conda</p>
<h3 dir="auto">Bug report</h3>
<p dir="auto"><strong>Bug summary</strong></p>
<p dir="auto">Generating <code class="notranslate">np.random.randn(1000)</code> values, visualizing them with <code class="notranslate">plt.hist()</code>. Works fine with Numpy.</p>
<p dir="auto">When I replace Numpy with tensorflow.experimental.numpy, Matplotlib 3.3.4 fails to display the histogram correctly. Matplotlib 3.2.2 works fine.</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="import matplotlib.pyplot as plt
import numpy as np
import tensorflow as tf
import tensorflow.experimental.numpy as tnp

# bad image
labels1 = 15 + 2 * tnp.random.randn(1000)
_ = plt.hist(labels1)

# good image
labels2 = 15 + 2 * np.random.randn(1000)
_ = plt.hist(labels2)"><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-k">import</span> <span class="pl-s1">numpy</span> <span class="pl-k">as</span> <span class="pl-s1">np</span>
<span class="pl-k">import</span> <span class="pl-s1">tensorflow</span> <span class="pl-k">as</span> <span class="pl-s1">tf</span>
<span class="pl-k">import</span> <span class="pl-s1">tensorflow</span>.<span class="pl-s1">experimental</span>.<span class="pl-s1">numpy</span> <span class="pl-k">as</span> <span class="pl-s1">tnp</span>

<span class="pl-c"># bad image</span>
<span class="pl-s1">labels1</span> <span class="pl-c1">=</span> <span class="pl-c1">15</span> <span class="pl-c1">+</span> <span class="pl-c1">2</span> <span class="pl-c1">*</span> <span class="pl-s1">tnp</span>.<span class="pl-s1">random</span>.<span class="pl-en">randn</span>(<span class="pl-c1">1000</span>)
<span class="pl-s1">_</span> <span class="pl-c1">=</span> <span class="pl-s1">plt</span>.<span class="pl-en">hist</span>(<span class="pl-s1">labels1</span>)

<span class="pl-c"># good image</span>
<span class="pl-s1">labels2</span> <span class="pl-c1">=</span> <span class="pl-c1">15</span> <span class="pl-c1">+</span> <span class="pl-c1">2</span> <span class="pl-c1">*</span> <span class="pl-s1">np</span>.<span class="pl-s1">random</span>.<span class="pl-en">randn</span>(<span class="pl-c1">1000</span>)
<span class="pl-s1">_</span> <span class="pl-c1">=</span> <span class="pl-s1">plt</span>.<span class="pl-en">hist</span>(<span class="pl-s1">labels2</span>)</pre></div>
<p dir="auto"><strong>Actual outcome</strong></p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/901867/109069736-7b499280-76a6-11eb-87c4-2880aaf759f5.png"><img src="https://user-images.githubusercontent.com/901867/109069736-7b499280-76a6-11eb-87c4-2880aaf759f5.png" alt="np-bad" style="max-width: 100%;"></a></p>
<p dir="auto"><strong>Expected outcome</strong></p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/901867/109069769-843a6400-76a6-11eb-9d2e-149fc615c583.png"><img src="https://user-images.githubusercontent.com/901867/109069769-843a6400-76a6-11eb-9d2e-149fc615c583.png" alt="np-good" style="max-width: 100%;"></a></p>
<p dir="auto"><strong>Matplotlib version</strong></p>

<ul dir="auto">
<li>Operating system: Windows 10</li>
<li>Matplotlib version (<code class="notranslate">import matplotlib; print(matplotlib.__version__)</code>): 3.3.4</li>
<li>Matplotlib backend (<code class="notranslate">print(matplotlib.get_backend())</code>): module://ipykernel.pylab.backend_inline</li>
<li>Python version: 3.8.7</li>
<li>Jupyter version (if applicable): see below</li>
<li>Other libraries: see below</li>
</ul>
<p dir="auto">TensorFlow 2.4.1</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="jupyter --version
jupyter core     : 4.7.0
jupyter-notebook : 6.1.6
qtconsole        : 5.0.1
ipython          : 7.20.0
ipykernel        : 5.4.2
jupyter client   : 6.1.7
jupyter lab      : not installed
nbconvert        : 6.0.7
ipywidgets       : 7.6.3
nbformat         : 5.0.8
traitlets        : 5.0.5"><pre class="notranslate"><code class="notranslate">jupyter --version
jupyter core     : 4.7.0
jupyter-notebook : 6.1.6
qtconsole        : 5.0.1
ipython          : 7.20.0
ipykernel        : 5.4.2
jupyter client   : 6.1.7
jupyter lab      : not installed
nbconvert        : 6.0.7
ipywidgets       : 7.6.3
nbformat         : 5.0.8
traitlets        : 5.0.5
</code></pre></div>
<p dir="auto">Python installed from python.org as an exe installer. Everything else is <code class="notranslate">pip install --user</code></p>
<p dir="auto">Bug opened with TensorFlow on this same issue:</p>
<p dir="auto"><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="781840855" data-permission-text="Title is private" data-url="https://github.com/tensorflow/tensorflow/issues/46274" data-hovercard-type="issue" data-hovercard-url="/tensorflow/tensorflow/issues/46274/hovercard" href="https://github.com/tensorflow/tensorflow/issues/46274">tensorflow/tensorflow#46274</a></p>