2016-02-06 8 views
0

我想在Python中使用cubehelix但是我一直在想我應該顯示的簡單問題。我正在使用的代碼如下:'module'對象在cubehelix中沒有屬性'cmap'python

import matplotlib.pyplot as plt import numpy as np import cubehelix

cx1 = cubehelix.cmap(reverse=True) alplot = plt.imshow(rtotal_rotated,vmax=1100,extent[-21,19,23,-17],cmap=cx1)

但是下面的錯誤出現,當我運行代碼:

AttributeError: 'module' object has no attribute 'cmap'

我知道這」沒錯,因爲我只是遵循本教程的代碼 http://www.ifweassume.com/2014/04/cubehelix-colormap-for-python.html

所以我不確定它爲什麼突破。

回答

0

非常喜歡這個腳本導入自己,即您的腳本被命名爲cubehelix.py。因此,如果您在當前工作目錄中有名爲cubehelix.py的文件,請將其重命名爲my_cubehelix.py,然後重試。

+0

這似乎並不奏效。當我重命名文件並改變我的文件中的所有內容時,它仍然不起作用 – Nat

相關問題