Suppose we have a dataset and are interested to understand relation in two variables. Bar plot comes in handy for such purpose.
So this recipe is a short example on How to plot horizontal and vertical bar plot using pandas. Let's get started.
import pandas as pd import seaborn as sb
Let's pause and look at these imports. Pandas is generally used for performing mathematical operation and preferably over arrays. Seaborn is just used in here to import dataset.
df = sb.load_dataset('tips')
Here we have imported tips dataset from seaborn library.
Now our dataset is ready.
Using barh, we have plotted horizontal bar plot and the vertical bar plot.
Once we run the above code snippet, we will see:
Scroll down to the ipython file to look at the results.
We can see bar plot for total bill vs sex in both horizontal and vertical form.