matplotlib - bar chart
This example showcases a simple bar chart.
- 1 example
"""
====================
bar chart
====================
This example showcases a simple bar chart.
"""
import matplotlib.pyplot as plt
import numpy as np
# Fixing random state for reproducibility
np.random.seed(19680801)
plt.rcdefaults()
fig, ax = plt.subplots()
# Example data
people = ('James', 'Durant', 'Kobe', 'Wade', 'Curry', 'Magic', 'Hardan')
x_pos = np.arange(len(people))
performance = 5 + 10 * np.random.rand(len(people))
error = np.random.rand(len(people)) / 4
plt.bar(x_pos, performance, xerr=error, align='center', alpha=0.9, color='green', ecolor='black')
plt.xticks(x_pos, people)
plt.ylabel('Performance')
plt.title('How efficient do you want to go today?')
plt.savefig("bar.png", format="png")
plt.show()
- 2 example
"""
====================
bar chart
====================
This example showcases a simple bar chart.
"""
import matplotlib.pyplot as plt
import numpy as np
# Fixing random state for reproducibility
np.random.seed(19680801)
plt.rcdefaults()
fig, ax = plt.subplots()
# Example data
people = ('James', 'Durant', 'Kobe', 'Wade', 'Curry', 'Magic', 'Hardan')
x_pos = np.arange(len(people))
performance = 5 + 10 * np.random.rand(len(people))
# error = np.random.rand(len(people)) / 4
# plt.bar(x_pos, performance, xerr=error, align='center', alpha=0.9, color='green', ecolor='black')
plt.bar(x_pos, performance, align='center', alpha=0.9, color='green', ecolor='black')
plt.xticks(x_pos, people)
plt.ylabel('Performance')
plt.title('How efficient do you want to go today?')
plt.savefig("bar.png", format="png")
plt.show()