title: Matplot histogram of Pytorch Tensor
body: <p>I have a tensor of size <code>10</code>, with only <code>1</code> values: <code>0</code> and <code>1</code>.</p>
  <p>I want to plot an histogram of the tensor above, simply using <code>matplotlib.pyplot.hist</code>. This is my code:</p>
  <pre><code>import torch
  import matplotlib.pyplot as plt
  t = torch.tensor([0., 1., 1., 1., 0., 1., 1., 0., 0., 0.])
  print(t)
  plt.hist(t, bins=2)
  plt.show()
  </code></pre>
  <p>And the output:</p>
  <p><a href="https://i.stack.imgur.com/vX9Xo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vX9Xo.png" alt="enter image description here" /></a></p>
  <p>Why are there so many values in the histogram? Where did the rest of the values come from? How can I plot a correct histogram for my tensor?</p>