本文整理汇总了Python中matplotlib.show函数的典型用法代码示例。如果您正苦于以下问题:Python show函数的具体用法?Python show怎么用?Python show使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了show函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: genCurve
def genCurve(dataSet, tree):
x = [] # stores the x axis of the graph
trainList = [] # the list of accuracies derived from training data
valList = [] # the list of accuracies derived from validation data
i = 0
while i < 1:
i = i+0.1
a = 0
b = 0
for trial in range(3):
newData = sortData(dataSet, i) # MAKE THIS
tree = getTree(newData) # NEED TO GET THIS FUNCTION WHEN TREEGEN WORKS
a = a + model_validation.validateTree(tree, newData)
b = b + model_validation.validateTree(tree, newData)
a = float(a)/3
b = float(b)/3
trainList.append(a)
valList.append(b)
x.append(i)
plt.plot(x, trainList)
plt.plot(x, valList)
plt.xlabel('percent training used')
plt.ylabel('percent accuracy')
plt.title('learning curve')
plt.show()
开发者ID:guiklink,项目名称:eecs349_machine_learning_hw2,代码行数:27,代码来源:make_graph.py
示例2: draw
def draw(self):
"""
Draw a network graph of the employee relationship.
"""
if self.graph is not None:
nx.draw_networkx(self.graph)
plt.show()
开发者ID:gcallah,项目名称:Indra,代码行数:7,代码来源:emp_model.py
示例3: showScatterPlot
def showScatterPlot(data, labels, idx1, idx2):
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(111)
# X-axis data, Y-axis data, Size for each sample, Color for each sample
ax.scatter(data[:,idx1], data[:,idx2], 100.0*(1 + np.array(labels)), 100.0*(1 + np.array(labels)))
plt.show()
开发者ID:timjong93,项目名称:MachineLearning,代码行数:7,代码来源:learn.py
示例4: plotRaster
def plotRaster(clustaArray=[]):
if len(clustaArray) < 1:
print "Nothing to plot!"
else:
# create list of times that maps to each spike
p_sptimes = []
for a in clustaArray:
for b in a.spike_samples:
p_sptimes.append(b)
sptimes = np.array(p_sptimes)
p_clusters = []
for c in clustaArray:
for d in c.id_of_spike:
p_clusters.append(c.id_of_clusta)
clusters = np.array(p_clusters)
# dynamically generate cluster list
clusterList = []
for a in clustaArray:
clusterList.append(a.id_of_clusta)
# plot raster for all clusters
# nclusters = 20
# #for n in range(nclusters):
timesList = []
for n in clusterList:
# if n<>9:
ctimes = sptimes[clusters == n]
timesList.append(ctimes)
plt.plot(ctimes, np.ones(len(ctimes)) * n, "|")
plt.show()
开发者ID:RaymondDunn,项目名称:branco_pipeline,代码行数:34,代码来源:generateGraphs.py
示例5: plotRetinaSpikes
def plotRetinaSpikes(retina=None, label=""):
assert retina is not None, "Network is not initialised! Visualising failed."
import matplotlib.pyplot as plt
from matplotlib import animation
print "Visualising {0} Spikes...".format(label)
spikes = [x.getSpikes() for x in retina]
# print spikes
sortedSpikes = sortSpikes(spikes)
# print sortedSpikes
framesOfSpikes = generateFrames(sortedSpikes)
# print framesOfSpikes
x = range(0, dimensionRetinaX)
y = range(0, dimensionRetinaY)
from numpy import meshgrid
rows, pixels = meshgrid(x,y)
fig = plt.figure()
initialData = createInitialisingData()
imNet = plt.imshow(initialData, cmap='green', interpolation='none', origin='upper')
plt.xticks(range(0, dimensionRetinaX))
plt.yticks(range(0, dimensionRetinaY))
args = (framesOfSpikes, imNet)
anim = animation.FuncAnimation(fig, animate, fargs=args, frames=int(simulationTime)*10, interval=30)
plt.show()
开发者ID:AMFtech,项目名称:StereoMatching,代码行数:34,代码来源:NetworkVisualiser.py
示例6: plotColorCodedNetworkSpikes
def plotColorCodedNetworkSpikes(network):
assert network is not None, "Network is not initialised! Visualising failed."
import matplotlib as plt
from NetworkBuilder import sameDisparityInd
cellsOutSortedByDisp = []
spikes = []
for disp in range(0, maxDisparity+1):
cellsOutSortedByDisp.append([network[x][2] for x in sameDisparityInd[disp]])
spikes.append([x.getSpikes() for x in cellsOutSortedByDisp[disp]])
sortedSpikes = sortSpikesByColor(spikes)
print sortedSpikes
framesOfSpikes = generateColoredFrames(sortedSpikes)
print framesOfSpikes
fig = plt.figure()
initialData = createInitialisingDataColoredPlot()
imNet = plt.imshow(initialData[0], c=initialData[1], cmap=plt.cm.coolwarm, interpolation='none', origin='upper')
plt.xticks(range(0, dimensionRetinaX))
plt.yticks(range(0, dimensionRetinaY))
plt.title("Disparity Map {0}".format(disparity))
args = (framesOfSpikes, imNet)
anim = animation.FuncAnimation(fig, animate, fargs=args, frames=int(simulationTime)*10, interval=30)
plt.show()
开发者ID:AMFtech,项目名称:StereoMatching,代码行数:29,代码来源:NetworkVisualiser.py
示例7: plot_images
def plot_images(header):
''' function to plot images from header.
It plots images, return nothing
Parameters
----------
header : databroker header object
header pulled out from central file system
'''
# prepare header
if type(list(headers)[1]) == str:
header_list = list()
header_list.append(headers)
else:
header_list = headers
for header in header_list:
uid = header.start.uid
img_field = _identify_image_field(header)
imgs = np.array(get_images(header, img_field))
print('Plotting your data now...')
for i in range(imgs.shape[0]):
img = imgs[i]
plot_title = '_'.join(uid, str(i))
# just display user uid and index of this image
try:
fig = plt.figure(plot_title)
plt.imshow(img)
plt.show()
except:
pass # allow matplotlib to crash without stopping other function
开发者ID:tacaswell,项目名称:xpdAcq,代码行数:31,代码来源:analysis.py
示例8: showScatterPlot
def showScatterPlot(data, idx1, idx2):
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(111)
# X-axis data, Y-axis data, Size for each sample, Color for each sample
ax.scatter(data[:,idx1], data[:,idx2])
plt.show()
开发者ID:timjong93,项目名称:MachineLearning,代码行数:8,代码来源:learn.py
示例9: draw
def draw(self):
positions = {}
Tree.get_positions(self, positions, x=(0, 10), y=(0, 10))
g = self.to_graph()
plt.axis('on')
nx.draw_networkx(g, positions, node_size=1500, font_size=24, node_color='g')
plt.show()
开发者ID:ddolzhenko,项目名称:traning_algos_2016_06,代码行数:8,代码来源:trees.py
示例10: graficolog
def graficolog():
ax = plt.gca()
ax.set_yscale('log')
plt.plot(k, eff, 'go')
plt.plot(k, eaf, 'ro')
plt.plot(k, ebf, 'bo')
plt.grid(True)
plt.show()
开发者ID:masbicudo,项目名称:Trabalhos-UFRJ,代码行数:9,代码来源:p1q2.py
示例11: grafico
def grafico(e):
plt.plot(k, np.repeat(dfa, N+1), 'k-')
plt.plot(k, vff, 'go')
plt.plot(k, vaf, 'ro')
plt.plot(k, vbf, 'bo')
plt.axis([0, N, dfa - e, dfa + e])
plt.grid(True)
plt.show()
开发者ID:masbicudo,项目名称:Trabalhos-UFRJ,代码行数:10,代码来源:p1q2.py
示例12: plotDataFrame
def plotDataFrame(self, variables):
try:
import matplotlib.pyplot as plt
except ImportError:
print "Unable to import matplotlib"
plt.plot(self.df[variables[0]], self.df[variables[1]])
plt.xlabel(r"{}".format(variables[0]))
plt.ylabel(r"$P$")
plt.minorticks_on()
plt.show()
开发者ID:dsmiff,项目名称:pandasUtils,代码行数:10,代码来源:pandasCore.py
示例13: plotSolutions
def plotSolutions(x,states=None): #Default func values is trivial
plt.figure(figsize=(11,8.5))
#get the exact values
f = open('exact_results.txt', 'r')
x_e = []
u_e = []
p_e = []
rho_e = []
e_e = []
for line in f:
if len(line.split())==1:
t = line.split()
else:
data = line.split()
x_e.append(float(data[0]))
u_e.append(float(data[1]))
p_e.append(float(data[2]))
rho_e.append(float(data[4]))
e_e.append(float(data[3]))
if states==None:
raise ValueError("Need to pass in states")
else:
u = []
p = []
rho = []
e = []
for i in states:
u.append(i.u)
p.append(i.p)
rho.append(i.rho)
e.append(i.e)
#get edge values
x_cent = [0.5*(x[i]+x[i+1]) for i in range(len(x)-1)]
if u != None:
plot2D(x_cent,u,"$u$",x_ex=x_e,y_ex=u_e)
if rho != None:
plot2D(x_cent,rho,r"$\rho$",x_ex=x_e,y_ex=rho_e)
if p != None:
plot2D(x_cent,p,r"$p$",x_ex=x_e,y_ex=p_e)
if e != None:
plot2D(x_cent,e,r"$e$",x_ex=x_e,y_ex=e_e)
plt.show(block=False) #show all plots generated to this point
raw_input("Press anything to continue...")
plot2D.fig_num=0
开发者ID:jhansel,项目名称:radhydro,代码行数:54,代码来源:muscl_hanc.py
示例14: epipolar_geometry
def epipolar_geometry(frame1, frame2):
#sift = cv2.SIFT()
# Find the keypoints and descriptors with SIFT
#kp1, des1 = sift.detectAndCompute(frame1, None)
#kp2, des2 = sift.detectAndCompute(frame2, None)
# Trying ORB instead of SIFT
orb = cv2.ORB()
kp1, des1 = orb.detectAndCompute(frame1, None)
kp2, des2 = orb.detectAndCompute(frame2, None)
des1, des2 = map(numpy.float32, (des1, des2))
# FLANN parameters
FLANN_INDEX_KDTREE = 0
index_params = dict(algorithm = FLANN_INDEX_KDTREE, trees = 5)
search_params = dict(checks = 50)
flann = cv2.FlannBasedMatcher(index_params, search_params)
matches = flann.knnMatch(des1, des2, k=2)
good, pts1, pts2 = [], [], []
# Ratio test as per Lowe's paper
for i, (m, n) in enumerate(matches):
if m.distance < 0.8*n.distance:
good.append(m)
pts1.append(kp1[m.queryIdx].pt)
pts2.append(kp2[m.trainIdx].pt)
pts1 = numpy.float32(pts1)
pts2 = numpy.float32(pts2)
F, mask = cv2.findFundamentalMat(pts1, pts2, cv2.FM_LMEDS)
return F, mask
pts1 = pts1[mask.ravel() == 1]
pts2 = pts2[mask.ravel() == 1]
lines1 = cv2.computeCorrespondEpilines(pts2.reshape(-1, 1, 2), 2, F)
lines1 = lines1.reshape(-1, 3)
img1, _ = drawlines(frame1, frame2, lines1, pts1, pts2)
lines2 = cv2.computeCorrespondEpilines(pts1.reshape(-1, 1, 2), 2, F)
lines2 = lines2.reshape(-1, 3)
img2, _ = drawlines(frame2, frame1, lines2, pts2, pts1)
matplotlib.pyplot.subplot(121)
matplotlib.pyplot.imshow(img1)
matplotlib.pyplot.subplot(122)
matplotlib.pyplot.imshow(img2)
matplotlib.show()
开发者ID:jwaixs,项目名称:opensportfit,代码行数:54,代码来源:stereocam.py
示例15: compress_kmeans
def compress_kmeans(im, k=4):
height, width, depth = im.shape
data = im.reshape((height * width, depth))
labels, centers = kmeans(data, k, 1e-2)
rep = closest(data, centers)
data_compressed = centers[rep]
im_compressed = data_compressed.reshape((height, width, depth))
plt.figure()
plt.imshow(im_compressed)
plt.show()
开发者ID:JonasSejr,项目名称:MLAU,代码行数:12,代码来源:compress.py
示例16: plot
def plot(data):
fig = plt.figure(figsize=plt.figaspect(2.))
ax = fig.add_subplot(2, 1, 1)
ax.set_ylabel(r'$\alpha$',size=20)
ax.set_xlabel('$N_C$',size=20)
l = ax.plot(data[:,0],data[:,3],'r')
l = ax.plot(data[:,0],data[:,4],'k--')
ax = fig.add_subplot(2, 1, 2)
ax.set_ylabel(r'$\beta$',size=20)
ax.set_xlabel('$N_C$',size=20)
l = ax.plot(data[:,0],data[:,1],'r')
l = ax.plot(data[:,0],data[:,2],'k--')
plt.show()
开发者ID:kleikanger,项目名称:vmc,代码行数:13,代码来源:plot.py
示例17: plotHistogram
def plotHistogram(clustaArray=[]):
if len(clustaArray) < 1:
print "Nothing to plot!"
else:
# create list of times that maps to each spike
p_sptimes = []
for a in clustaArray:
for b in a.spike_samples:
p_sptimes.append(b)
sptimes = np.array(p_sptimes)
p_clusters = []
for c in clustaArray:
for d in c.id_of_spike:
p_clusters.append(c.id_of_clusta)
clusters = np.array(p_clusters)
# dynamically generate cluster list
clusterList = []
for a in clustaArray:
clusterList.append(a.id_of_clusta)
# plot raster for all clusters
# nclusters = 20
# #for n in range(nclusters):
timesList = []
for n in clusterList:
# if n<>9:
ctimes = sptimes[clusters == n]
timesList.append(ctimes)
# plt.plot(ctimes, np.ones(len(ctimes))*n, '|')
# plt.show()
# plot frequency in Hz over time
dt = 1 / 30000.0 # in seconds
binSize = 1 # in seconds
binSizeSamples = round(binSize / dt)
recLen = np.max(sptimes)
nbins = round(recLen / binSizeSamples)
binCount = []
cluster = 3
for b in np.arange(0, nbins - 1):
n = np.sum((timesList[cluster] > b * binSizeSamples) & (timesList[cluster] < (b + 1) * binSizeSamples))
binCount.append(n / binSize) # makes Hz
plt.plot(binCount)
plt.ylim([0, 20])
plt.show()
开发者ID:RaymondDunn,项目名称:branco_pipeline,代码行数:50,代码来源:generateGraphs.py
示例18: plot_confusion_matrix
def plot_confusion_matrix(cm, labels, title='Confusion matrix', cmap=plt.cm.Blues, save=False):
plt.figure()
plt.imshow(cm, interpolation='nearest', cmap=cmap)
plt.title(title)
plt.colorbar()
tick_marks = np.arange(len(labels))
plt.xticks(tick_marks, labels, rotation=45)
plt.yticks(tick_marks, labels)
plt.tight_layout()
plt.ylabel('True label')
plt.xlabel('Predicted label')
plt.show()
if save:
plt.savefig(save)
开发者ID:johnnyzithers,项目名称:sample-tagging,代码行数:14,代码来源:machine_learning.py
示例19: plotDisparityHistogram
def plotDisparityHistogram(network=None):
assert network is not None, "Network is not initialised! Visualising failed."
import matplotlib.pyplot as plt
from NetworkBuilder import sameDisparityInd
spikesPerDisparityMap = []
for d in range(0, maxDisparity-minDisparity+1):
cellsOut = [network[x][1] for x in sameDisparityInd[d]]
spikesPerDisparityMap.append(sum([sum(x.get_spike_counts().values()) for x in cellsOut]))
print spikesPerDisparityMap
plt.bar(range(0, maxDisparity-minDisparity+1), spikesPerDisparityMap, align='center')
plt.show()
开发者ID:AMFtech,项目名称:StereoMatching,代码行数:15,代码来源:NetworkVisualiser.py
示例20: lets_paint_the_world
def lets_paint_the_world(file):
filee = open(filename)
filee
lon = []
lat = []
depth = []
counter = 0
for line in filee.readlines(): #set a counter because computer couldn't run the whole file
if counter < 1000:
each_line = line.split()
lon.append(float(each_line[0][:]))
lat.append(float(each_line[1][:]))
depth.append(float(each_line[2][:]))
counter += 1
m = Basemap(projection = 'tmerc',
llcrnrlon= -180,
urcrnrlon = 180,
llcrnrlat= -90,
urcrnrlat = 90,
lat_0= 0,
lon_0= 0)
#creates the graticule based on the coor
x, y = m(*np.meshgrid(lon,lat))#<----------BREAKING POINT
#plot commands
fig = plt.figure(figsize=(10,7))
ax = fig.add_subplot(111)
#draws
m.fillcontinents(color='coral', lake_color='aqua')
m.drawcoastlines(linewidth = .25)
m.drawcountries(linewidth = .25)
m.drawmeridians(np.arange(0, 360, 15))
m.drawparallels(np.arange(-90, 90, 15))
plt.pcolormesh(x,y,depth, [-1000,0,1000], cmap=plt.cm.RdBu_r, vmin=-100, vmax = 100)
plt.show()
开发者ID:JordanMakesMaps,项目名称:pg2014_Pierce,代码行数:47,代码来源:homework5.py
注:本文中的matplotlib.show函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论