How to plot bar chart in Python using matplotlib.pyplot ? Argument height must be 'xxxx' or scalar -
i have data frame named 'train' has number of variables. 1 such variable 'industry'. first 10 elements of column 'industry' follows:
train['industry'][:10] 0 office supplies 1 unknown 2 misc services 3 social services 4 unknown 5 manufacturing 6 social services 7 office supplies 8 entertainment 9 construction name: industry, dtype: object
i trying plot bar chart using matplotlib.pyplot plt library industry type on x-axis , frequency on y-axis. not sure should value of 'height' argument?
plt.bar(train['industry'], height = )
height frequency. here's example
make array of length
len(train.index)
make bar chart without industry names -
plt.bar(array, frequency)
. frequency/height cannot string. needs numerical. if isn't, convert usingpd.to_numeric
put industry names array
use
set_xticklabels(industries)
change labels
Comments
Post a Comment