Reputation: 10324
I expected "b" to be plotted the same way as "a", but it's not:
import matplotlib.pyplot as plt
import numpy as np
figure, axes = plt.subplots(nrows = 2, ncols = 1)
a = [[1, 2, 2, 3, 3, 3], [1, 1, 1, 2, 2, 3]]
b = np.array(object = a)
axes[0].hist(x = a, bins = np.arange(start = 0, stop = 5, step = 1), density = True)
axes[1].hist(x = b, bins = np.arange(start = 0, stop = 5, step = 1), density = True)
figure.show()
Why?
Upvotes: 2
Views: 50
Reputation: 280261
matplotlib.axes.Axes.hist
just does that. It's weird.
Multiple data can be provided via x as a list of datasets of potentially different length ([x0, x1, ...]), or as a 2-D ndarray in which each column is a dataset. Note that the ndarray form is transposed relative to the list form.
If you pass a list of datasets, each row is a dataset. If you pass a 2D array, each column is a dataset.
Upvotes: 5