为什么单独导入matplotlib时无法识别matplotlib.cm.jet?
Why is matplotlib.cm.jet not recognized while importing matplotlib alone?
我尝试使用以下代码获取 matplotlib.cm.jet:
import matplotlib
print(matplotlib.cm.jet)
不幸的是,我收到以下错误:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-3-ae42efdc0f9b> in <module>
----> 1 light = matplotlib.cm.jet
AttributeError: module 'matplotlib' has no attribute 'cm'
但是,如果我包含 import matplotlib.pyplot as plt,它会很好用!!!!
import matplotlib
import matplotlib.pyplot as plt
print(matplotlib.cm.jet)
输出:
<matplotlib.colors.LinearSegmentedColormap object at 0x00000136974123D0>
为什么会这样?
正如 T 先生和 BigBen 评论得很好,这是一个问题,因为我使用的 Matplotlib 版本(3.3.1,也在 3.4.3 版本中复制)。
(...) seemingly they forgot to include cm in the directory. – Mr. T
更新到版本 3.5.1 解决了这个问题。
谢谢大家!
我尝试使用以下代码获取 matplotlib.cm.jet:
import matplotlib
print(matplotlib.cm.jet)
不幸的是,我收到以下错误:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-3-ae42efdc0f9b> in <module>
----> 1 light = matplotlib.cm.jet
AttributeError: module 'matplotlib' has no attribute 'cm'
但是,如果我包含 import matplotlib.pyplot as plt,它会很好用!!!!
import matplotlib
import matplotlib.pyplot as plt
print(matplotlib.cm.jet)
输出:
<matplotlib.colors.LinearSegmentedColormap object at 0x00000136974123D0>
为什么会这样?
正如 T 先生和 BigBen 评论得很好,这是一个问题,因为我使用的 Matplotlib 版本(3.3.1,也在 3.4.3 版本中复制)。
(...) seemingly they forgot to include cm in the directory. – Mr. T
更新到版本 3.5.1 解决了这个问题。
谢谢大家!