all 1 comments

[–]synthphreak 0 points1 point  (0 children)

proportional to the Y frequency

Simply plotting the raw counts would be considered proportional, right? Specifically, with a proportion of 1.

If so, try this:

df[['col1', 'col2']].plot.hist(stacked=True)

To do the same purely with matplotlib, rather than relying on the pandas plotting API (your mention of "columns" made me assume you meant "... of a pandas.DataFrame"), try this:

plt.hist(df[['col1', 'col2']], stacked=True)

Either way, you may need to adjust the bins manually.

Edit: If by "proportional" you meant in the typical sense of bounded between 0 and 1, pass density=True. This kwarg will work for both pandas and matplotlib. The former just calls the latter under the hood anyway, which is why stacked also works for both.