This might seem a very naive thing but I just want to ensure if my understanding is correct.
To plot directly from pandas dataframe as a shortcut, my first option is to call the plot() method and pass in my x and y and the kind of the plot I want to make. Otherwise, I can assign the dataframe as a pandas.plotting._core.PlotAccessor object to plot and then call the appropriate method for plotting like bar(), box() etc.
So, syntactically I have
df.plot(x=x, y=y, kind='something') # call method OR
df.plot.something(x=x, y=y) # assign object and then call method
If my above claims are correct, then why I don't get what I intend for univariate plots (hist, box, etc)? Although it works perfectly fine for bivariate ones.
df = pd.DataFrame({'col1':[1,2,3,4], 'col2':[3,3,5,5], 'col3':[10,11,12,13]})
df.plot(x='col1', kind='hist') # or
df.plot.hist(x='col2')
gives a graph like
I understand that according to Pandas Documentation I should be using a Series by slicing the col2 for the same, but then what is the purpose of the x and y?
Also, this works as expected for bivariate plots like
df.plot.scatter(x='col1', y='col3')
What am I missing? Any help is appreciated. Thanks in advance.



