Fill in the missing code

Report a typo

Finish the code below so that it results in a plot below:

import matplotlib.pyplot as plt

payment_method = ['Debit', 'Credit', 'Cash', 'Other']
statistics = [48, 33, 9, 10]
colors = ['lightblue', 'yellowgreen', 'coral', 'gold']

# YOUR CODE HERE #

plt.xlabel('Number of transactions (%)')
plt.ylabel('Methods')
plt.title('Preferred payment methods in 2014')
plt.show()

Plot a horizontal bar chart with different colors

The answer should be in the following format:

plt.barh(...)

Tip: To give each bar a different color, pass the list of colors to the color parameter.

Enter a short text
___

Create a free account to access the full topic