You need to change the first line of your code to the following:
import matplotlib.pyplot as plt
The second line of code is okay, but I don't understand what the third line of code is doing. What dataframe are you trying to print? I copied and pasted a dataframe from the web and then ran your code changing the first and third lines of code.
All runs good in Jupyter Lab using the python kernel.
import matplotlib.pyplot as plt
from matplotlib import pyplot
df = pd.DataFrame({
'name':['john','mary','peter','jeff','bill','lisa','jose'],
'age':[23,78,22,19,45,33,20],
'gender':['M','F','M','M','M','F','M'],
'state':['california','dc','california','dc','california','texas','texas'],
'num_children':[2,0,0,3,2,1,4],
'num_pets':[5,1,0,5,2,2,3]
})
df.plot(kind='hist',x='num_children',y='num_pets',color='red')
plt.show()
The plot can be viewed at the link below.
link