3.4 Column Chart

1. Column Chart

What to learn:

  • Set figure size

  • Plot with numerical variables and categorical variables

  • Change column color

  • Create a horizontal bar chart

plt.figure(figsize = (8,6))                     # set the figure size

performance = [70,95, 61, 88,82]                # y_axis values
student = ['Mavin','Lily','Tim','Ben','Julian'] # x_axis values
y_pos = np.arange(len(student))                 # calculate number of "student"

plt.bar(y_pos,performance,color = 'orange')  # create bars, set the orange color 
plt.xticks(y_pos,student)       #Create names on the x-axis
plt.show()
Column Chart

2. Horizontal Column Chart

Horizontal Column Chart

3. Stacked Column Chart

What to learn:

  • The difference of Stacked Column Chart and Grouped Column Chart

  • Plot two groups of bars on one figure

  • Choose the proper chart

Stacked Column Chart

Obviously, this is a bad choice. The stacked bar can't show the trends nor differences clearly. Meanwhile. the stack makes y_axis value non-sense. Nobody grows to 3.5 meters!

So we should alternate to the grouped bar chart.

4. Grouped Column Chart

Now, it looks much better and makes more sense.

Grouped Column Chart

Last updated

Was this helpful?