I have a data frame as follow:
and I am trying to plot a histogram from it such that the letters {A,B,C,D} are in the x axis and y axis shows the numbers. I have tried the following:
df.plot(kind='hist')
for which I get the address instead of the plot, i.e:
<matplotlib.axes._subplots.AxesSubplot at 0x11217d5f8>
I was wondering how can I show the plot?
IIUC, I think you need to transpose the dataframe
to get index ['A','B','C','D']
as x-axis and then plot. Also use plt.show()
to display the histogram. The latest version of pandas will display directly the plot with axes object displaying. But, for the older versions need to explicitly write the plt.show()
code to display.
import matplotlib.pyplot as plt
df.T.plot(kind='hist')
plt.show()
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments