0

I am plotting 3D data and used these

import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')

Spyder shows a warning (but plotting works fine)

"mpl_toolkits.mplot3d.Axes3D" imported but unused. 

If I don't import, I get an error when I run the .py file.

ValueError: Unknown projection '3d'

Why is this module required when it is not being used.

Pierre de Buyl
  • 7,074
  • 2
  • 16
  • 22
SEU
  • 1,304
  • 4
  • 15
  • 36
  • I would guess that Spyder is looking for an explicit namespace call of the Axes3D object, but you never actually call it explicitly because you are only using it for the projection argument. – BHawk Nov 07 '17 at 17:15
  • The module *is* used. But Spyder cannot know that it is used because *you* don't use it in the code - internally the `projection='3d'` will make sure it is used. To avoid the warning, you can use `projection=Axes3D.name` as shown in the duplicate. – ImportanceOfBeingErnest Nov 07 '17 at 17:43

0 Answers0