2014-05-03 104 views
0

我有一個定義,我用imshow幾個小腳本使用的顏色表定義的顏色表...導入不同的文件

的顏色表是在自己colormap.py文件看起來像這樣:

import matplotlib 

#define colorcode for matrix 
cdict = {'red': ((0,1,1), 
       (0.2,0,0), 
       (0.5,0.275,0.275), 
       (0.7,1,1), 
       (1,1,1) 
       ), 
     'green': ((0,1,1), 
        (0.2,0.275,0.275), 
        (0.5,1,1), 
        (0.7,1,1), 
        (1,0,0) 
        ), 
     'blue': ((0,1,1), 
        (0.2,1,1), 
        (0.5,0,0), 
        (0.7,0,0), 
        (1,0,0) 
       )} 
FFT_colormap = matplotlib.colors.LinearSegmentedColormap('my_colormap',cdict,256) 

現在我有一個腳本的另一個文件,我想繪製一個矩陣。我要的是它的工作原理是這樣的代碼:

from colormap.py import FFT_colormap 
import pylab as pl 

pl.imshow(data, cmap=FFT_colormap) 

嗯......因爲FFT_colormap是沒有的功能,我不能導入它這樣。那麼有沒有辦法導入這樣的色彩地圖?

回答

-1

我找到了解決辦法....

execfile('colorcodes.py')的的ColorCode加載到我的新腳本...

+0

好吧,如果這是錯誤的解決方案,請讓我知道..... ... – FrankTheTank

相關問題