Skip to content

Instantly share code, notes, and snippets.

@audhiaprilliant
Created November 2, 2022 14:43
Show Gist options
  • Select an option

  • Save audhiaprilliant/8a8849725356653fb83aec3480ad8ce9 to your computer and use it in GitHub Desktop.

Select an option

Save audhiaprilliant/8a8849725356653fb83aec3480ad8ce9 to your computer and use it in GitHub Desktop.
Matplotlib 101 - Basic Introduction for Python Beginner
# ---------- 2nd ITERATION - REORDER THE CATEGORIES AND DO COLORING ----------
# Reorder the PaymentMethod based on total customer
df_group_1.sort_values(by = 'customerID', ascending = False, inplace = True)
# Figure size
fig = plt.figure(figsize = (10, 4.8))
# Bar plot
bar_fig = plt.bar(
x = 'PaymentMethod',
height = 'customerID',
data = df_group_1,
width = 0.5
);
# Set colors
colors = ['#981220', '#80797C', '#80797C', '#80797C']
for i in range(len(colors)):
bar_fig[i].set_color(colors[i])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment