本文整理汇总了Python中matplotlib.pylab.matshow函数的典型用法代码示例。如果您正苦于以下问题:Python matshow函数的具体用法?Python matshow怎么用?Python matshow使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了matshow函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: validate
def validate(X_test, y_test, pipe, title, fileName):
print('Test Accuracy: %.3f' % pipe.score(X_test, y_test))
y_predict = pipe.predict(X_test)
confusion_matrix = np.zeros((9,9))
for p,r in zip(y_predict, y_test):
confusion_matrix[p-1,r-1] = confusion_matrix[p-1,r-1] + 1
print (confusion_matrix)
confusion_normalized = confusion_matrix.astype('float') / confusion_matrix.sum(axis=1)[:, np.newaxis]
print (confusion_normalized)
pylab.clf()
pylab.matshow(confusion_normalized, fignum=False, cmap='Blues', vmin=0.0, vmax=1.0)
ax = pylab.axes()
ax.set_xticks(range(len(families)))
ax.set_xticklabels(families, fontsize=4)
ax.xaxis.set_label_position('top')
ax.xaxis.set_ticks_position("top")
ax.set_yticks(range(len(families)))
ax.set_yticklabels(families, fontsize=4)
pylab.title(title)
pylab.colorbar()
pylab.grid(False)
pylab.grid(False)
pylab.savefig(fileName, dpi=900)
开发者ID:tlabruyere,项目名称:CS544-Cyber,代码行数:30,代码来源:kNeighbor.py
示例2: BreakIllustration
def BreakIllustration(seed=11):
for x in [1 , 2 , 4, 8, 16 , 25, 100]:
pylab.clf()
m4=GenKolmogorovV2(1025, seed, pybnlib.Kol3DBreakLaw(1.0/x) )
pylab.matshow(m4)
pylab.savefig("temp/breakill-%03i.png" % x)
开发者ID:bnikolic,项目名称:oof,代码行数:7,代码来源:kolmogorov.py
示例3: PlotTurbulenceIllustr
def PlotTurbulenceIllustr(a):
"""
Can generate the grid with
g=kolmogorovutils.GenerateKolmogorov3D( 1025, 129, 129)
a=kolmogorovutils.GridToNumarray(g)
"""
for x in [1,10,100]:
suba= numarray.sum(a[:,:,0:x], axis=2)
suba.transpose()
pylab.clf()
pylab.matshow(suba)
pylab.savefig("temp/turb3d-sum%03i.eps" % x)
for x in [1,10,100]:
for j in [0,1,2]:
suba= numarray.sum(a[:,:200,j*x:(j+1)*x], axis=2)
suba.transpose()
pylab.clf()
pylab.matshow(suba)
pylab.savefig("temp/turb3d-sum%03i-s%i.eps" % (x,j))
开发者ID:bnikolic,项目名称:oof,代码行数:28,代码来源:kolmogorov3d.py
示例4: Animate
def Animate(g):
for i in range(1,64,5):
pylab.clf()
x= g[0:i,:,:]
y= numarray.sum(x, axis=0)
pylab.matshow( y)
pylab.savefig("temp/3dturb-%03i.png" % i)
开发者ID:bnikolic,项目名称:oof,代码行数:7,代码来源:kolmogorov3d.py
示例5: plot_confusion_matrix
def plot_confusion_matrix(cm, meow_list, name, title):
pylab.clf()
pylab.matshow(cm, fignum=False, cmap='Blues', vmin=0, vmax=1.0)
ax = pylab.axes()
ax.set_xticks(range(len(meow_list)))
ax.set_xticklabels(meow_list)
ax.xaxis.set_ticks_position("bottom")
开发者ID:FosterCL1,项目名称:cat_monitor,代码行数:7,代码来源:OrganizeUntestedDirectory.py
示例6: showKernel
def showKernel(dataOrMatrix, fileName = None, useLabels = True, **args) :
labels = None
if hasattr(dataOrMatrix, 'type') and dataOrMatrix.type == 'dataset' :
data = dataOrMatrix
k = data.getKernelMatrix()
labels = data.labels
else :
k = dataOrMatrix
if 'labels' in args :
labels = args['labels']
import matplotlib
if fileName is not None and fileName.find('.eps') > 0 :
matplotlib.use('PS')
from matplotlib import pylab
pylab.matshow(k)
#pylab.show()
if useLabels and labels.L is not None :
numPatterns = 0
for i in range(labels.numClasses) :
numPatterns += labels.classSize[i]
#pylab.figtext(0.05, float(numPatterns) / len(labels), labels.classLabels[i])
#pylab.figtext(float(numPatterns) / len(labels), 0.05, labels.classLabels[i])
pylab.axhline(numPatterns, color = 'black', linewidth = 1)
pylab.axvline(numPatterns, color = 'black', linewidth = 1)
pylab.axis([0, len(labels), 0, len(labels)])
if fileName is not None :
pylab.savefig(fileName)
pylab.close()
开发者ID:Grater,项目名称:Sentiment-Analysis,代码行数:33,代码来源:ker.py
示例7: show_profile
def show_profile(task, fn):
data = zeros((task.Sx, task.Sy))
for i in range(task.Sx):
for j in range(task.Sy):
data[i][j] = fn(task.Gp(i, j, task.Sz / 2))
plb.matshow(data.transpose())
plb.colorbar()
plb.show()
开发者ID:wanygen,项目名称:uestc-cemlab-fdtd,代码行数:8,代码来源:fdtd.py
示例8: PlotSTest
def PlotSTest(a):
from matplotlib import pylab
x = numpy.mean(a, axis=0)
x.shape = (int(len(x) ** 0.5), int(len(x) ** 0.5))
pylab.matshow(x)
pylab.colorbar()
开发者ID:bnikolic,项目名称:oof,代码行数:8,代码来源:k3d_structretest.py
示例9: plot_dependency_posterior
def plot_dependency_posterior(df, meta, t, num_joints=None):
if num_joints is None:
num_joints = determine_num_joints(df)
plt.figure()
posterior=np.array([df["Posterior%d"%j].iloc[t] for j in range(num_joints)])
plt.matshow(posterior, interpolation='nearest')
plt.show()
开发者ID:hildensia,项目名称:joint_dependency,代码行数:8,代码来源:interpret_results.py
示例10: group_causality
def group_causality(sig_list, condition, freqs, ROI_labels=None,
out_path=None, submount=10):
"""
Make group causality analysis, by evaluating significant matrices across
subjects.
----------
sig_list: list
The path list of individual significant causal matrix.
condition: string
One condition of the experiments.
freqs: list
The list of interest frequency band.
min_subject: string
The subject for the common brain space.
submount: int
Significant interactions come out at least in 'submount' subjects.
"""
print 'Running group causality...'
set_directory(out_path)
sig_caus = []
for f in sig_list:
sig_cau = np.load(f)
print sig_cau.shape[-1]
sig_caus.append(sig_cau)
sig_caus = np.array(sig_caus)
sig_group = sig_caus.sum(axis=0)
plt.close()
for i in xrange(len(sig_group)):
fmin, fmax = freqs[i][0], freqs[i][1]
cau_band = sig_group[i]
# cau_band[cau_band < submount] = 0
cau_band[cau_band < submount] = 0
# fig, ax = pl.subplots()
cmap = plt.get_cmap('hot', cau_band.max()+1-submount)
cmap.set_under('gray')
plt.matshow(cau_band, interpolation='nearest', vmin=submount, cmap=cmap)
if ROI_labels == None:
ROI_labels = np.arange(cau_band.shape[0]) + 1
pl.xticks(np.arange(cau_band.shape[0]), ROI_labels, fontsize=9, rotation='vertical')
pl.yticks(np.arange(cau_band.shape[0]), ROI_labels, fontsize=9)
# pl.imshow(cau_band, interpolation='nearest')
# pl.set_cmap('BlueRedAlpha')
np.save(out_path + '/%s_%s_%sHz.npy' %
(condition, str(fmin), str(fmax)), cau_band)
v = np.arange(submount, cau_band.max()+1, 1)
# cax = ax.scatter(x, y, c=z, s=100, cmap=cmap, vmin=10, vmax=z.max())
# fig.colorbar(extend='min')
plt.colorbar(ticks=v, extend='min')
# pl.show()
plt.savefig(out_path + '/%s_%s_%sHz.png' %
(condition, str(fmin), str(fmax)), dpi=300)
plt.close()
return
开发者ID:dongqunxi,项目名称:jumeg,代码行数:58,代码来源:apply_causality_whole.py
示例11: savematrixplot
def savematrixplot(datasetname,tumorname, A, k):
"""
plt.figure("%s_consensus_rank_%d.png" % (tumorname,k))
plt.subplot(211)
plt.matshow(A)
plt.savefig("./" + datasetname + "_results/%s_consensus_rank_%d.png" % (tumorname,k))
"""
mplpl.matshow(A)
mplpl.savefig("./" + datasetname + "_results/%s_consensus_rank_%d.png" % (tumorname,k))
开发者ID:jdrooks,项目名称:UMBCS697CC4,代码行数:9,代码来源:phase1_transpose.py
示例12: create_heatmaps
def create_heatmaps(df, key=lambda t: t.minute):
for group, data in df.groupby(df.index.map(key)):
all_mat = np.zeros((100,100), dtype=np.int)
for x, y in zip(data.x, data.y):
all_mat[x, y] += 1
all_mat = all_mat*1.0/len(data)
plt.matshow(all_mat)
plt.title(data.ix[0].name)
print("saving: ", group)
plt.savefig("{:02}.png".format(group))
开发者ID:ice3,项目名称:VAST_2015,代码行数:10,代码来源:test_pandas.py
示例13: plot_grid
def plot_grid(self, name="", save_figure=True):
"""
This plots the 2D representation of the grid
:param name: the name of the image to save
:return:
"""
plt.matshow(self.matrix_grid(), cmap="RdBu", fignum=0)
# Option to save images
if save_figure:
plt.savefig(self.path + name + '.png')
开发者ID:StuartGordonReid,项目名称:Ant-Colony-Optimization,代码行数:10,代码来源:Ants.py
示例14: plotArray
def plotArray( xyarray, colormap=mpl.cm.gnuplot2, normMin=None, normMax=None, showMe=True,
cbar=False, cbarticks=None, cbarlabels=None, plotFileName='arrayPlot.png',
plotTitle='', sigma=None):
"""
Plots the 2D array to screen or if showMe is set to False, to file. If normMin and
normMax are None, the norm is just set to the full range of the array.
"""
if sigma != None:
meanVal = np.mean(accumulatePositive(xyarray))
stdVal = np.std(accumulatePositive(xyarray))
normMin = meanVal - sigma*stdVal
normMax = meanVal + sigma*stdVal
if normMin == None:
normMin = xyarray.min()
if normMax == None:
normMax = xyarray.max()
norm = mpl.colors.Normalize(vmin=normMin,vmax=normMax)
figWidthPt = 550.0
inchesPerPt = 1.0/72.27 # Convert pt to inch
figWidth = figWidthPt*inchesPerPt # width in inches
figHeight = figWidth*1.0 # height in inches
figSize = [figWidth,figHeight]
params = {'backend': 'ps',
'axes.labelsize': 10,
'axes.titlesize': 12,
'text.fontsize': 10,
'legend.fontsize': 10,
'xtick.labelsize': 10,
'ytick.labelsize': 10,
'figure.figsize': figSize}
plt.rcParams.update(params)
plt.matshow(xyarray, cmap=colormap, origin='lower',norm=norm)
if cbar:
if cbarticks == None:
cbar = plt.colorbar(shrink=0.8)
else:
cbar = plt.colorbar(ticks=cbarticks, shrink=0.8)
if cbarlabels != None:
cbar.ax.set_yticklabels(cbarlabels)
plt.ylabel('Row Number')
plt.xlabel('Column Number')
plt.title(plotTitle)
if showMe == False:
plt.savefig(plotFileName)
# else:
# plt.show()
plt.close()
开发者ID:RupertDodkins,项目名称:ARCONS-pipeline-1,代码行数:52,代码来源:sdssutils.py
示例15: plot_block_matrix
def plot_block_matrix(labels, tProb_, name='BlockMatrix'):
print "Plot Block Matrix"
indices = np.argsort(labels)
#print indices
block_matrix = tProb_[:,indices]
block_matrix = block_matrix[indices,:]
block_matrix = 1 - block_matrix
#print block_matrix
pylab.matshow(block_matrix, cmap=plt.cm.OrRd)
plt.colorbar()
plt.savefig('./' + name + '.png', dpi=400)
#pylab.show()
plt.close()
开发者ID:liusong299,项目名称:HK_DataMiner,代码行数:13,代码来源:plot_.py
示例16: predict
def predict(X, y, model):
labels = model.predict(X).flatten()
n_samples = X.shape[0]
err = float(np.sum(y != labels))/n_samples
print "Prediction error of ", err, "."
cm = sklearn.metrics.confusion_matrix(y, labels)
row_sum = cm.sum(axis=1).reshape(cm.shape[0], 1)
print "Frequencies of each class:", row_sum
cm = cm.astype(float)/row_sum
plt.matshow(cm)
plt.title("Confusion Matrix")
plt.colorbar()
plt.show()
开发者ID:cwein3,项目名称:im-seg,代码行数:13,代码来源:patch_class.py
示例17: simular
def simular(self):
pass
i=0
g = []
while True:
pass
if (self.uf.find(self.cell(0,0),self.cell(self.N-1,self.N-1))):
plt.plot(g)
plt.show()
pll.matshow(self.celda)
pll.show()
return int(i)
i=i+1
g.append(i/self.N*self.N)
self.step()
开发者ID:juankp,项目名称:PercolacionCP,代码行数:15,代码来源:Percolation.py
示例18: main
def main():
parser = ap.ArgumentParser()
parser.add_argument('--data_dir', type=str, default='../data_helpers/', help='Folder containing data splits.')
parser.add_argument('--data', type=str, help='The location of the data file we are using.')
parser.add_argument('--mode', type=str, help='Either PREDICT or TRAIN. Will predict on test dataset or train on new dataset accordingly.')
parser.add_argument('--old_model', type=str, default=None, help='The file location of the neural network model. If this is None, we will train a model from scratch, but this needs to be specified for predict.')
parser.add_argument('--num_hidden', type=int, default=1000, help='The number of hidden layers in the classifier.')
parser.add_argument('--n_iter', type=int, default=2, help='Number of iterations of gradient descent to use.')
parser.add_argument('--outfile', type=str, help='The file which we output the trained model to.')
parser.add_argument('--lr', type=float, default=0.01, help='Learning rate to use.')
parser.add_argument('--allowed_num', type=int, help='The allowed number of training examples for one class.')
parser.add_argument('--name_map', type=str, default='classmap.pkl', help='Name of the pickle file which stores the class map.')
parser.add_argument('--num_split', type=int, default='13', help='The number of training splits to do.')
parser.add_argument('--predict_set', type=str, default='test', help='Whether we predict on train or test.')
parser.add_argument('--lr_decay', type=float, default=0.75, help='Learning rate decay every time we pass over a split.')
parser.add_argument('--hardcode', type=bool, default=False, help='Whether to hardcode allowed number of classes.')
global args
args = parser.parse_args()
class_map = allowed_classes if args.hardcode else pickle.load(open(args.name_map, "r"))
num_classes = len(class_map)
model = None if args.old_model is None else pickle.load(open(args.old_model, "r"))
if args.mode == 'TRAIN':
lr = args.lr
for _ in xrange(args.n_iter):
for split in xrange(args.num_split):
data_loc = args.data_dir + ("trainsplit%d" % split) + args.data
X, y, w = convert_data(data_loc, class_map)
model = train(X, y, w, num_classes, model, lr)
lr *= args.lr_decay
if args.mode == 'PREDICT':
all_predict = np.array([])
all_labels = np.array([])
for split in xrange(args.num_split):
data_loc = args.data_dir + (args.predict_set + "split%d" % split) + args.data
X, y, _ = convert_data(data_loc, class_map)
all_predict = np.concatenate((all_predict, predict_split(X, y, model)), axis=0)
all_labels = np.concatenate((all_labels, y), axis=0)
n_samples = all_labels.size
err = float(np.sum(all_predict != all_labels))/n_samples
print "Prediction error of ", err, "."
cm = sklearn.metrics.confusion_matrix(all_labels, all_predict)
row_sum = cm.sum(axis=1).reshape(cm.shape[0], 1)
print "Frequencies of each class:", row_sum
cm = cm.astype(float)/row_sum
plt.matshow(cm)
plt.title("Confusion Matrix")
plt.colorbar()
plt.show()
开发者ID:cwein3,项目名称:im-seg,代码行数:48,代码来源:patch_class_splits.py
示例19: PlotTurbulenceIllustrZFlat
def PlotTurbulenceIllustrZFlat(g):
"Like PlotTurbulenceIllustr but use the ZFlatten routine"
Nx, Ny, Nz = g[1]
for x in [1,10,100]:
res=ZFlatten(g,x)
na=kolmogorovutils.GridToNumarray( (res, (Nx,Ny,1)))
na=na[:,:,0]
na.transpose()
pylab.clf()
pylab.matshow(na)
pylab.savefig("temp/turb3d-zflatsum%03i.eps" % x)
开发者ID:bnikolic,项目名称:oof,代码行数:16,代码来源:kolmogorov3d.py
示例20: plot_confusion_matrix
def plot_confusion_matrix(cm, genre_list, name="", title=""):
pylab.clf()
pylab.matshow(cm, fignum=False, cmap=plt.cm.Blues)
ax = pylab.axes()
ax.set_xticks(range(len(genre_list)))
ax.set_xticklabels(genre_list)
ax.xaxis.set_ticks_position("bottom")
ax.set_yticks(range(len(genre_list)))
ax.set_yticklabels(genre_list)
#pylab.title(title)
pylab.colorbar()
pylab.grid(False)
pylab.xlabel('Predicted class')
pylab.ylabel('True class')
pylab.grid(False)
pylab.show()
开发者ID:yuchi1989,项目名称:music-genre-classification-and-chord-sequence,代码行数:16,代码来源:experiment1.py
注:本文中的matplotlib.pylab.matshow函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论