I want to visualize a bar plot with 2 classes. Class=0 its color blue and class=1 its color red.
#here its my code
x = ['0','1']
real = df[df['fake'] == 0].count()
fake = df[df['fake'] == 1].count()
plt.bar(x, real, color='blue')
plt.bar(x, fake, color='red')
plt.title("Class Fake & Real")
plt.show()
Error code : ValueError: shape mismatch: objects cannot be broadcast to a single shape
CodePudding user response:
from matplotlib import pyplot as plt
x = ['0', '1']
real, fake = 5, 10
plt.bar(x[0], real, color='blue')
plt.bar(x[1], fake, color='red')
plt.title("Class Fake & Real")
plt.show()
Your error may comes from wrong types of real
and fake
. BTW, for configuring different colors for bars, there is a better