Advertisements
Advertisements
Question
What would happen if we use df.plot(kind=’scatter’) instead of plt.scatter() in the program?
import numpy as np
import matplotlib.pyplot as plt
discount= np.array([10,20,30,40,50])
saleInRs=np.array([40000,45000,48000,50000,100000])
size=discount*10
plt.scatter(x=discount,y=saleInRs,s=size,color='red',linewidth=3,m
arker='*',edgecolor='blue'
plt.title('Sales Vs Discount')
plt.xlabel('Discount offered')
plt.ylabel('Sales in Rs')
plt.show()Short Answer
Advertisements
Solution
If df.plot(kind='scatter') is used instead of plt.scatter(), the scatter plot will be created using the Pandas DataFrame. It requires specifying the x and y columns of the DataFrame, whereas plt.scatter() plots are directly from arrays. The output remains a scatter plot.
shaalaa.com
Is there an error in this question or solution?
