Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I'm a Python 3.6 user and I've been trying to learn how to use the matplotlib and pandas libraries. But as 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'

like image 353
William Avatar asked Jul 17 '17 17:07

William


1 Answers

Do not use

import matplotlib as plt 

but rather use

import matplotlib.pyplot as plt 

plt is an abbreviation for pyplot, which is a module inside the matplotlib package. You need to address it for the kinds of things you are doing, not just matplotlib.

Note that matplotlib can be used without using pyplot at all, but most people find it easier to use pyplot. See its documentation or the tutorial for details.

like image 100
Rory Daulton Avatar answered Oct 02 '22 17:10

Rory Daulton