Not sure why I keep getting an error when I try to plot a bar chart.
def plotBar(x,y):
plt.bar(x, y, width=1, align='center', color='plum', edgecolor='firebrick',linewidth=1)
plt.show()
In main I am calling the function like this:
x1=np.arange(1,101)
y1=np.arange(50,151)
classname.plotBar(x1,y1)
However, I keep getting this error:
TypeError: plotBar() takes 2 positional arguments but 3 were given
def plotBar(self,x,y):since it seems to be a class method of classnameclassname.plotBar(x1,y1)It seems like you've tried to create a class that has a method calledplotBar. When creating a method, the first variable (often calledself) is the class instance. You can try to changeplotBar(x,y)intoplotBar(self,x,y).