Bar Char


Bar Chart :


bar chart or bar graph is a chart or graph that presents categorical data with rectangular bars with heights or lengths proportional to the values that they represent. The bars can be plotted vertically or horizontally.

- The following is a function you can use to plot a bar chart :


def bar_plot(var, xlabel, ylabel, title):
    df[var].value_counts().plot(kind = 'bar', figsize = (15, 10))
    plt.xlabel(xlabel)
    plt.ylabel(ylabel)
    plt.title(title)




- using the function to plot the value_counts of a variable named "Cost_Center"

bar_plot('Cost_Center', 'Cost Center', 'No of items demanded', 'No of items demanded by each department')

Comments