Hi, I was trying some code from WesMckinney's python data analysis book in ipython environment,which is built in anaconda. When I typed the simple code like
import matplotlib.pyplot as plt
fig = plt.figure
ax1 = fig.add_subplot(2,2,1)
Traceback (most recent call last):
File "<ipython-input-9-559e30a6412a>", line 1, in <module>
ax1 = fig.add_subplot(2,2,1)
AttributeError: 'function' object has no attribute 'add_subplot'
An AttributeError arose, but it's weird since anaconda is surely installed with matplotlib module. So Any suggestion? thank you.
The issue is that you don't have the open and close brackets (()) at the end of plt.figure, so you haven't actually created a figure, just assigned a handle fig to the plt.figure function. Instead, try:
import matplotlib.pyplot as plt
fig = plt.figure() #Here is your error
ax1 = fig.add_subplot(2,2,1)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With