Updating color of bar chart - Pyplot of Mathplotlib Module

Updating color of bar chart - Pyplot of Mathplotlib Module

Instructor-svgAl-Mamun Sarkar
Apr 02 , 2020

Updating color of bar chart - Pyplot of Mathplotlib Module. The following codes shows how to update color of bar chart using pyplot of python mathplotlib module.

 

Import Module:

import matplotlib.pyplot as plt

 

Create data and plot bar chart and update color:

x_data = [2, 4, 6, 8, 10]
y_data = [6, 7, 8, 2, 4]

another_x = [1, 3, 5, 7, 9]
another_y = [7, 8, 2, 4, 2]

plt.bar(x_data, y_data, label='Bar Chart', color='r')
plt.bar(another_x, another_y, label='Another Bar Chart', color='c')
plt.title("Welcome to bar chart ploting tutorial \n This is Another Line")
plt.xlabel('X-Axis')
plt.ylabel('Y-Axis')
plt.legend()
plt.show()

  • Share On:
  • fb
  • twitter
  • pinterest
  • instagram