Plt.hist(some_data) vs. plt.hist(data = some_data)


what is the mechanical difference between plt.hist(some_data) vs. plt.hist(data = some_data) ?
when I input plt.hist(data = some_data) error is thrown say x is missing value when I put plt.hist(data = some_data, x = some_value_in_some_data) another error is thrown: len() of unsized object

the expression: plt.hist(some_data) has worked for me so far, but I would like to know what is changed by putting data = some_data as opposed to mere some_data.


plt.hist() takes two parameters: an array (you can import Numpy for this too) and the number of bins. (there’s a bunch of other parameters and keyword argument options too for further customization). See:



And for Seaborn it’s just a little bit different:

Where you can supply the data and either x or y values.


When in doubt the docs are always a good look-in:
The data argument makes it convenient to pass things like dictionaries or dataframes (indexable containers).

For example-

my_data = {'A': [1, 2, 3,], 'B': [-4, -5, -6,],}
plt.hist(x='A', data=my_data)

It’s a bit easier that way, they’re not immediately interchangeable items though.