本文整理汇总了Python中matplotlib.pylab.show函数的典型用法代码示例。如果您正苦于以下问题:Python show函数的具体用法?Python show怎么用?Python show使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了show函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: plot_cone
def plot_cone():
'''
'''
from base import plot as pf
c = cone_hc()
stimulus, response = c.simulate()
fig = plt.figure()
fig.set_tight_layout(True)
#ax1 = fig.add_subplot(211)
ax2 = fig.add_subplot(111)
pf.AxisFormat()
#pf.TufteAxis(ax1, ['left'], [5, 5])
pf.TufteAxis(ax2, ['left', 'bottom'], [5, 5])
#ax1.semilogy(stimulus, 'k')
ax2.plot(response, 'k')
ax2.plot((stimulus / np.max(stimulus)) * 31, 'k')
#ax1.set_xlim([0, 2000])
ax2.set_xlim([0, 3000])
ax2.set_ylim([30, 40])
#ax1.set_ylabel('luminance (td)')
ax2.set_ylabel('normalized response')
ax2.set_xlabel('time')
plt.show()
开发者ID:bps10,项目名称:base,代码行数:27,代码来源:hc_widefield.py
示例2: bo_
def bo_(x_obs, y_obs):
kernel = kernels.Matern() + kernels.WhiteKernel()
gp = GaussianProcessRegressor(kernel=kernel, n_restarts_optimizer=16)
gp.fit(x_obs, y_obs)
xs = list(repeat(np.atleast_2d(np.linspace(0, 10, 128)).T, 2))
x = cartesian_product(*xs)
a = a_EI(gp, x_obs=x_obs, y_obs=y_obs)
argmin_a_x = x[np.argmax(a(x))]
# heavy evaluation
print("f({})".format(argmin_a_x))
f_argmin_a_x = f2d(np.atleast_2d(argmin_a_x))
plot_2d(gp, x_obs, y_obs, argmin_a_x, a, xs)
plt.show()
bo_(
x_obs=np.vstack((x_obs, argmin_a_x)),
y_obs=np.hstack((y_obs, f_argmin_a_x)),
)
开发者ID:Jim-Holmstroem,项目名称:bayesian-optimization,代码行数:25,代码来源:poc.py
示例3: display_grid
def display_grid(grid, **kwargs):
fig = plt.figure()
plt.axes().set_aspect('equal')
if kwargs.get('mark_core_cells', True):
core_cell_coords = grid._cell_nodes[1:-1, 1:-1]
cellx, celly = core_cell_coords[:, :, 0], core_cell_coords[:, :, 1]
plt.plot(cellx, celly, '-o', np.transpose(cellx), np.transpose(celly), '-o', color='red')
if kwargs.get('mark_boundary_cells', True):
boundary_cell_coords = grid._cell_nodes[0, :], \
grid._cell_nodes[-1, :], \
grid._cell_nodes[1:-1, 0], \
grid._cell_nodes[1:-1, -1]
for coords in boundary_cell_coords:
plt.plot(coords[:, 0], coords[:, 1], '-x', color='blue')
if kwargs.get('show', False):
plt.show()
f = BytesIO()
plt.savefig(f)
return f
开发者ID:obrienadam,项目名称:latte,代码行数:25,代码来源:viewers.py
示例4: plotConeSpace
def plotConeSpace():
'''
'''
space = colorSpace(fundamental='neitz',
LMSpeaks=[559.0, 530.0, 421.0])
space.plotColorSpace(space.Lnorm, space.Mnorm, space.spectrum)
plt.show()
开发者ID:bps10,项目名称:color,代码行数:7,代码来源:plot_colorSpace.py
示例5: plot_values
def plot_values(self, TITLE, SAVE):
plot(self.list_of_densities, self.list_of_pressures)
title(TITLE)
xlabel("Densities")
ylabel("Pressure")
savefig(SAVE)
show()
开发者ID:Schoyen,项目名称:molecular-dynamics-fys3150,代码行数:7,代码来源:PlotPressureNumber.py
示例6: plot_grid_experiment_results
def plot_grid_experiment_results(grid_results, params, metrics):
global plt
params = sorted(params)
grid_params = grid_results.grid_params
plt.figure(figsize=(8, 6))
for metric in metrics:
grid_params_shape = [len(grid_params[k]) for k in sorted(grid_params.keys())]
params_max_out = [(1 if k in params else 0) for k in sorted(grid_params.keys())]
results = np.array([e.results.get(metric, 0) for e in grid_results.experiments])
results = results.reshape(*grid_params_shape)
for axis, included_in_params in enumerate(params_max_out):
if not included_in_params:
results = np.apply_along_axis(np.max, axis, results)
print results
params_shape = [len(grid_params[k]) for k in sorted(params)]
results = results.reshape(*params_shape)
if len(results.shape) == 1:
results = results.reshape(-1,1)
import matplotlib.pylab as plt
#f.subplots_adjust(left=.2, right=0.95, bottom=0.15, top=0.95)
plt.imshow(results, interpolation='nearest', cmap=plt.cm.hot)
plt.title(str(grid_results.name) + " " + metric)
if len(params) == 2:
plt.xticks(np.arange(len(grid_params[params[1]])), grid_params[params[1]], rotation=45)
plt.yticks(np.arange(len(grid_params[params[0]])), grid_params[params[0]])
plt.colorbar()
plt.show()
开发者ID:gmum,项目名称:mlls2015,代码行数:31,代码来源:utils.py
示例7: plot_dichromatic_system
def plot_dichromatic_system(hybrid='ls', clip=True):
'''
'''
space = colorSpace(fundamental='neitz', LMSpeaks=[559, 530, 421])
space.plotColorSpace()
for x in np.arange(0, 1.1, 0.1):
if hybrid.lower() == 'ls' or hybrid.lower() == 'sl':
s = x
m = 0
l = -(1.0 - x)
elif hybrid.lower() == 'lm' or hybrid.lower() == 'ml':
s = 0
m = x
l = -(1.0 - x)
elif hybrid.lower() == 'ms' or hybrid.lower() == 'sm':
s = x
m = -(1.0 - x)
l = 0
else:
raise InputError('hybrid must be ls, lm or ms')
copunct = space.lms_to_rgb([l, m, s])
neutral_points = space.find_spect_neutral(copunct)
for neut in neutral_points:
space.cs_ax.plot([neut[0], copunct[0]], [neut[1], copunct[1]],
'-o', c=(np.abs(l), np.abs(m), np.abs(s)),
markersize=8, linewidth=2)
if clip is True:
space.cs_ax.set_xlim([-0.4, 1.2])
space.cs_ax.set_ylim([-0.2, 1.2])
plt.show()
开发者ID:bps10,项目名称:color,代码行数:34,代码来源:plot_colorSpace.py
示例8: item_nbr_tendency
def item_nbr_tendency(store_nbr):
'''
input : store_nbr
output : graph representing units groupped by each year, each month
'''
store = df_1[df_1['store_nbr'] == store_nbr]
pivot = store.pivot_table(index=['year','month'],columns='item_nbr',values='units',aggfunc=np.sum)
zero_index = pivot==0
pivot = pivot[pivot!=0].dropna(axis=1,how='all')
pivot[zero_index]=0
pivot_2012 = pivot.loc[2012]
pivot_2013 = pivot.loc[2013]
pivot_2014 = pivot.loc[2014]
plt.figure(figsize=(12,8))
plt.subplot(131)
sns.heatmap(pivot_2012,cmap="YlGnBu", annot = True, fmt = '.0f')
plt.subplot(132)
sns.heatmap(pivot_2013,cmap="YlGnBu", annot = True, fmt = '.0f')
plt.subplot(133)
sns.heatmap(pivot_2014,cmap="YlGnBu", annot = True, fmt = '.0f')
plt.show()
开发者ID:atyams,项目名称:kaggle-walmart-sales-in-stormy-weather,代码行数:25,代码来源:jw_package.py
示例9: test_params
def test_params():
#x = np.linspace(.8, 1.2, 1e2)
x = np.linspace(-.2, .2, 1e2)
num = 5
range_a = np.linspace(1, 2, num)
range_b = np.linspace(1., 1.1, num)
range_p = np.linspace(.1, .4, num)
range_q = np.linspace(.1, .4, num)
range_T = np.linspace(30, 365, num) / 365
args_def = {'a' : range_a.mean(), 'b' : range_b.mean(),
'p' : range_p.mean(), 'q' : range_q.mean(),
'T' : range_T.mean()}
ranges = {'a' : range_a, 'b' : range_b,
'p' : range_p, 'q' : range_q, 'T' : range_T}
fig, axes = plt.subplots(nrows = len(ranges), figsize = (6,12))
for name, a in zip(sorted(ranges.keys()), axes):
args = args_def.copy()
for pi in ranges[name]:
args[name] = pi
f = GB2(**args).density(x)
a.plot(x, f, label = pi)
a.legend(title = name)
plt.show()
开发者ID:khrapovs,项目名称:rndensity,代码行数:27,代码来源:beta_distribution.py
示例10: plot_q
def plot_q(model='cem', r_min=0.0, r_max=6371.0, dr=1.0):
"""
Plot a radiallysymmetric Q model.
plot_q(model='cem', r_min=0.0, r_max=6371.0, dr=1.0):
r_min=minimum radius [km], r_max=maximum radius [km], dr=radius
increment [km]
Currently available models (model): cem, prem, ql6
"""
import matplotlib.pylab as plt
r = np.arange(r_min, r_max + dr, dr)
q = np.zeros(len(r))
for k in range(len(r)):
if model == 'cem':
q[k] = q_cem(r[k])
elif model == 'ql6':
q[k] = q_ql6(r[k])
elif model == 'prem':
q[k] = q_prem(r[k])
plt.plot(r, q, 'k')
plt.xlim((0.0, r_max))
plt.xlabel('radius [km]')
plt.ylabel('Q')
plt.show()
开发者ID:krischer,项目名称:ses3d_ctrl,代码行数:30,代码来源:Q_models.py
示例11: item_nbr_tendency_finely
def item_nbr_tendency_finely(store_nbr, year, month_start=-1, month_end=-1, graph=True):
'''
input
1. store_nbr = 스토어 번호
2. year = 연도
3. month_start = 시작달
4. month_start = 끝달
5. graph = 위의 정보에 대한 item_nbr 그래프 출력여부
output
1. store_nbr, year, month로 filtering한 item_nbr의 pivot 테이블
'''
store = df_1[(df_1['store_nbr'] == store_nbr) &
(df_1['year'] == year)]
if month_start != -1:
if month_end == -1:
month_end = month_start + 1
store = store[(month_start <= store['month']) & (store['month'] < month_end)]
pivot = store.pivot_table(index='item_nbr',
columns='date',
values='units',
aggfunc=np.sum)
zero_index = pivot == 0
pivot = pivot[pivot != 0].dropna(axis=0, how='all')
pivot[zero_index] = 0
if graph:
plt.figure(figsize=(12, 8))
sns.heatmap(pivot, cmap="YlGnBu", annot=True, fmt='.0f')
plt.show()
return pivot
开发者ID:atyams,项目名称:kaggle-walmart-sales-in-stormy-weather,代码行数:35,代码来源:jw_package.py
示例12: plotting
def plotting():
# plt.ion()
countries = ['France', 'Spain', 'Sweden', 'Germany', 'Finland', 'Poland',
'Italy',
'United Kingdom', 'Romania', 'Greece', 'Bulgaria', 'Hungary',
'Portugal', 'Austria', 'Czech Republic', 'Ireland',
'Lithuania', 'Latvia',
'Croatia', 'Slovakia', 'Estonia', 'Denmark', 'Netherlands',
'Belgium']
extensions = [547030, 504782, 450295, 357022, 338145, 312685, 301340,
243610, 238391,
131940, 110879, 93028, 92090, 83871, 78867, 70273, 65300,
64589, 56594,
49035, 45228, 43094, 41543, 30528]
populations = [63.8, 47, 9.55, 81.8, 5.42, 38.3, 61.1, 63.2, 21.3, 11.4,
7.35,
9.93, 10.7, 8.44, 10.6, 4.63, 3.28, 2.23, 4.38, 5.49, 1.34,
5.61,
16.8, 10.8]
life_expectancies = [81.8, 82.1, 81.8, 80.7, 80.5, 76.4, 82.4, 80.5, 73.8,
80.8, 73.5,
74.6, 79.9, 81.1, 77.7, 80.7, 72.1, 72.2, 77, 75.4,
74.4, 79.4, 81, 80.5]
data = {'extension': pd.Series(extensions, index=countries),
'population': pd.Series(populations, index=countries),
'life expectancy': pd.Series(life_expectancies, index=countries)}
df = pd.DataFrame(data)
print(df)
df = df.sort('life expectancy')
fig, axes = plt.subplots(nrows=3, ncols=1)
for i, c in enumerate(df.columns):
df[c].plot(kind='bar', ax=axes[i], figsize=(12, 10), title=c)
plt.show()
开发者ID:laurogama,项目名称:mlpython,代码行数:34,代码来源:main.py
示例13: flipPlot
def flipPlot(minExp, maxExp):
"""假定minEXPy和maxExp是正整数且minExp<maxExp
绘制出2**minExp到2**maxExp次抛硬币的结果
"""
ratios = []
diffs = []
aAxis = []
for i in range(minExp, maxExp+1):
aAxis.append(2**i)
for numFlips in aAxis:
numHeads = 0
for n in range(numFlips):
if random.random() < 0.5:
numHeads += 1
numTails = numFlips - numHeads
ratios.append(numHeads/numFlips)
diffs.append(abs(numHeads-numTails))
plt.figure()
ax1 = plt.subplot(121)
plt.title("Difference Between Heads and Tails")
plt.xlabel('Number of Flips')
plt.ylabel('Abs(#Heads - #Tails)')
ax1.semilogx(aAxis, diffs, 'bo')
ax2 = plt.subplot(122)
plt.title("Heads/Tails Ratios")
plt.xlabel('Number of Flips')
plt.ylabel("#Heads/#Tails")
ax2.semilogx(aAxis, ratios, 'bo')
plt.show()
开发者ID:xiaohu2015,项目名称:ProgrammingPython_notes,代码行数:29,代码来源:chapter12.py
示例14: test_likelihood_evaluator3
def test_likelihood_evaluator3():
tr = template.TemplateRenderCircleBorder()
tr.set_params(14, 6, 4)
t1 = tr.render(0, np.pi/2)
img = np.zeros((240, 320), dtype=np.uint8)
env = util.Environmentz((1.5, 2.0), (240, 320))
le2 = likelihood.LikelihoodEvaluator3(env, tr)
img[(120-t1.shape[0]/2):(120+t1.shape[0]/2),
(160-t1.shape[1]/2):(160+t1.shape[1]/2)] += t1 *255
pylab.subplot(1, 2, 1)
pylab.imshow(img, interpolation='nearest', cmap=pylab.cm.gray)
state = np.zeros(1, dtype=util.DTYPE_STATE)
xvals = np.linspace(0, 2., 100)
yvals = np.linspace(0, 1.5, 100)
res = np.zeros((len(yvals), len(xvals)), dtype=np.float32)
for yi, y in enumerate(yvals):
for xi, x in enumerate(xvals):
state[0]['x'] = x
state[0]['y'] = y
state[0]['theta'] = np.pi / 2.
res[yi, xi] = le2.score_state(state, img)
pylab.subplot(1, 2, 2)
pylab.imshow(res)
pylab.colorbar()
pylab.show()
开发者ID:ericmjonas,项目名称:franktrack,代码行数:32,代码来源:test_likelihood.py
示例15: plotGetSelection
def plotGetSelection():
""" Get data range from selected pen.
"""
selData = []
if len(ds.EpmDatasetAnalysisPens.SelectedPens) != 1:
sr.msgBox('EPM Python Plugin - Demo Tools', 'Please select a single pen before applying this function!', 'Warning')
return 0
epmData = ds.EpmDatasetAnalysisPens.SelectedPens[0].values
y = epmData['Value'].copy()
x = np.arange(len(y))
fig = pl.figure(figsize=(8,6))
ax = fig.add_subplot(211, axisbg='#FFFFCC')
ax.plot(x, y, '-')
ax.set_title('Press left mouse button and drag to test')
ax2 = fig.add_subplot(212, axisbg='#FFFFCC')
line2, = ax2.plot(x, y, '-')
def onselect(xmin, xmax):
selData.append([xmin, xmax])
indmin, indmax = np.searchsorted(x, (xmin, xmax))
indmax = min(len(x)-1, indmax)
thisx = x[indmin:indmax]
thisy = y[indmin:indmax]
line2.set_data(thisx, thisy)
ax2.set_xlim(thisx[0], thisx[-1])
ax2.set_ylim(thisy.min(), thisy.max())
fig.canvas.draw()
span = SpanSelector(ax, onselect, 'horizontal', useblit=True, rectprops=dict(alpha=0.5, facecolor='red') )
pl.show()
return selData
开发者ID:sandrojapa,项目名称:python,代码行数:31,代码来源:DemoTools.py
示例16: _fig_density
def _fig_density(sweight, surweight, pval, nlm):
"""
Plot the histogram of sweight across the image
and the thresholds implied by the surrogate model (surweight)
"""
import matplotlib.pylab as mp
# compute some thresholds
nlm = nlm.astype('d')
srweight = np.sum(surweight,1)
srw = np.sort(srweight)
nitem = np.size(srweight)
thf = srw[int((1-min(pval,1))*nitem)]
mnlm = max(1,nlm.mean())
imin = min(nitem-1,int((1.-pval/mnlm)*nitem))
thcf = srw[imin]
h,c = np.histogram(sweight,100)
I = h.sum()*(c[1]-c[0])
h = h/I
h0,c0 = np.histogram(srweight,100)
I0 = h0.sum()*(c0[1]-c0[0])
h0 = h0/I0
mp.figure(1)
mp.plot(c,h)
mp.plot(c0,h0)
mp.legend(('true histogram','surrogate histogram'))
mp.plot([thf,thf],[0,0.8*h0.max()])
mp.text(thf,0.8*h0.max(),'p<0.2, uncorrected')
mp.plot([thcf,thcf],[0,0.5*h0.max()])
mp.text(thcf,0.5*h0.max(),'p<0.05, corrected')
mp.savefig('/tmp/histo_density.eps')
mp.show()
开发者ID:cindeem,项目名称:nipy,代码行数:32,代码来源:structural_bfls.py
示例17: plotGetRetangle
def plotGetRetangle():
""" Area selection from selected pen.
"""
selRect = []
if len(ds.EpmDatasetAnalysisPens.SelectedPens) != 1:
sr.msgBox('EPM Python Plugin - Demo Tools', 'Please select a single pen before applying this function!', 'Warning')
return 0
epmData = ds.EpmDatasetAnalysisPens.SelectedPens[0].values
y = epmData['Value'].copy()
x = np.arange(len(y))
fig, current_ax = pl.subplots()
pl.plot(x, y, lw=2, c='g', alpha=.3)
def line_select_callback(eclick, erelease):
'eclick and erelease are the press and release events'
x1, y1 = eclick.xdata, eclick.ydata
x2, y2 = erelease.xdata, erelease.ydata
print ("\n(%3.2f, %3.2f) --> (%3.2f, %3.2f)" % (x1, y1, x2, y2))
selRect.append((int(x1), y1, int(x2), y2))
def toggle_selector(event):
if event.key in ['Q', 'q'] and toggle_selector.RS.active:
toggle_selector.RS.set_active(False)
if event.key in ['A', 'a'] and not toggle_selector.RS.active:
toggle_selector.RS.set_active(True)
toggle_selector.RS = RectangleSelector(current_ax, line_select_callback, drawtype='box', useblit=True, button=[1,3], minspanx=5, minspany=5, spancoords='pixels')
pl.connect('key_press_event', toggle_selector)
pl.show()
return selRect
开发者ID:sandrojapa,项目名称:python,代码行数:29,代码来源:DemoTools.py
示例18: check_isometry
def check_isometry(G, chart, nseeds=100, verbose = 0):
"""
A simple check of the Isometry:
look whether the output distance match the intput distances
for nseeds points
Returns
-------
a scaling factor between the proposed and the true metrics
"""
nseeds = np.minimum(nseeds, G.V)
aux = np.argsort(nr.rand(nseeds))
seeds = aux[:nseeds]
dY = Euclidian_distance(chart[seeds],chart)
dx = G.floyd(seeds)
dY = np.reshape(dY,np.size(dY))
dx = np.reshape(dx,np.size(dx))
if verbose:
import matplotlib.pylab as mp
mp.figure()
mp.plot(dx,dY,'.')
mp.show()
scale = np.dot(dx,dY)/np.dot(dx,dx)
return scale
开发者ID:Garyfallidis,项目名称:nipy,代码行数:27,代码来源:dimension_reduction.py
示例19: viz_docwordfreq_sidebyside
def viz_docwordfreq_sidebyside(P1, P2, title1='', title2='',
vmax=None, aspect=None, block=False):
from matplotlib import pylab
pylab.figure()
if vmax is None:
vmax = 1.0
P1limit = np.percentile(P1.flatten(), 97)
if P2 is not None:
P2limit = np.percentile(P2.flatten(), 97)
else:
P2limit = P1limit
while vmax > P1limit and vmax > P2limit:
vmax = 0.8 * vmax
if aspect is None:
aspect = float(P1.shape[1])/P1.shape[0]
pylab.subplot(1, 2, 1)
pylab.imshow(P1, aspect=aspect, interpolation='nearest', vmin=0, vmax=vmax)
if len(title1) > 0:
pylab.title(title1)
if P2 is not None:
pylab.subplot(1, 2, 2)
pylab.imshow(P2, aspect=aspect, interpolation='nearest', vmin=0, vmax=vmax)
if len(title2) > 0:
pylab.title(title2)
pylab.show(block=block)
开发者ID:agile-innovations,项目名称:refinery,代码行数:27,代码来源:BirthMoveTopicModel.py
示例20: viz_birth_proposal_2D
def viz_birth_proposal_2D(curModel, newModel, ktarget, freshCompIDs,
title1='Before Birth',
title2='After Birth'):
''' Create before/after visualization of a birth move (in 2D)
'''
from ..viz import GaussViz, BarsViz
from matplotlib import pylab
fig = pylab.figure()
h1 = pylab.subplot(1,2,1)
if curModel.obsModel.__class__.__name__.count('Gauss'):
GaussViz.plotGauss2DFromHModel(curModel, compsToHighlight=ktarget)
else:
BarsViz.plotBarsFromHModel(curModel, compsToHighlight=ktarget, figH=h1)
pylab.title(title1)
h2 = pylab.subplot(1,2,2)
if curModel.obsModel.__class__.__name__.count('Gauss'):
GaussViz.plotGauss2DFromHModel(newModel, compsToHighlight=freshCompIDs)
else:
BarsViz.plotBarsFromHModel(newModel, compsToHighlight=freshCompIDs, figH=h2)
pylab.title(title2)
pylab.show(block=False)
try:
x = raw_input('Press any key to continue >>')
except KeyboardInterrupt:
import sys
sys.exit(-1)
pylab.close()
开发者ID:agile-innovations,项目名称:refinery,代码行数:30,代码来源:BirthMove.py
注:本文中的matplotlib.pylab.show函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论