Error with matplotlib.show (): matplotlib module has no attribute 'show'

I am a Python 3.6 user and I have been trying to learn how to use matplotlib and pandas libraries. But when I try to use the show () function, I get the following error:

import pandas as pd
import matplotlib as plt
df=pd.DataFrame({'Day':[1,2,3], 'Revenue':[100,200,320]})
df.plot()
plt.show()

      

ERROR: AttributeError: module 'matplotlib' has no attribute 'show'

+3


source to share


1 answer


Do not use

import matplotlib as plt

      

but use



import matplotlib.pyplot as plt

      

plt

is an abbreviation for pyplot

, which is a module within a package matplotlib

. You need to turn to him for the things that you do, and not just matplotlib

.

Note that matplotlib

it can be used without using pyplot

at all, but most people find it easier to use pyplot

. See its documentation for details .

+15


source







All Articles