本文整理汇总了Python中matplotlib.pyplot.waitforbuttonpress函数的典型用法代码示例。如果您正苦于以下问题:Python waitforbuttonpress函数的具体用法?Python waitforbuttonpress怎么用?Python waitforbuttonpress使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了waitforbuttonpress函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: plot_rocs
def plot_rocs(data, save_to=None):
import matplotlib.pyplot as plt
import palettable
colors = palettable.colorbrewer.qualitative.Set2_8.mpl_colors
fig, ax = plt.subplots(1)
i = 0
for filename, (xs, ys) in data:
auc_score = metrics.auc(xs, ys, reorder=False)
label = "%s (%.3f)" % (filename, auc_score)
ax.plot(xs, ys, '-', linewidth=1.2, color=colors[i], label=label)
i += 1
ax.plot([0.0, 1.0], [0.0, 1.0], '--', color='gray')
ax.set_ylabel("Portion Relevant")
ax.set_xlabel("Portion Irrelevant")
ax.set_title("ROC")
ax.set_xlim([0.0, 1.0])
ax.set_ylim([0.0, 1.0])
ax.legend(loc='lower right')
if save_to is None:
fig.show()
plt.waitforbuttonpress()
else:
fig.savefig(save_to)
fig.clf()
开发者ID:escherba,项目名称:recrec,代码行数:28,代码来源:recrec.py
示例2: manual_sync_pick
def manual_sync_pick(flow, gyro_ts, gyro_data):
# First pick good points in flow
plt.clf()
plt.plot(flow)
plt.title('Select two points')
selected_frames = [int(round(x[0])) for x in plt.ginput(2)]
# Now pick good points in gyro
plt.clf()
plt.subplot(211)
plt.plot(flow)
plt.plot(selected_frames, flow[selected_frames], 'ro')
plt.subplot(212)
plt.plot(gyro_ts, gyro_data.T)
plt.title('Select corresponding sequence in gyro data')
plt.draw()
selected = plt.ginput(2) #[int(round(x[0])) for x in plt.ginput(2)]
gyro_idxs = [(gyro_ts >= x[0]).nonzero()[0][0] for x in selected]
plt.plot(gyro_ts[gyro_idxs], gyro_data[:, gyro_idxs].T, 'ro')
plt.title('Ok, click to continue to next')
plt.draw()
plt.waitforbuttonpress(timeout=10.0)
plt.close()
return (tuple(selected_frames), gyro_idxs)
开发者ID:CHellebostad,项目名称:TestProgram,代码行数:26,代码来源:timesync.py
示例3: display_Direction
def display_Direction(centroid0,centroid1,k=None,cluster=None):
"""
display the histogramm of a vector
:arg centroid0: first centroid
:type centroid0: Observation
:arg centroid1: second centroid
:type centroid1: Observation
:param k: k of kmeans, for title
:type k: int
:param cluster: cluster whose direction is computed, for title
:type cluster: int
:rtype: void
"""
dx = float(abs(centroid0.values[0]-centroid1.values[0]))
dy = float(abs(centroid0.values[1]-centroid1.values[1]))
if (centroid0.values[0]-centroid1.values[0])*(centroid0.values[1]-centroid1.values[1]) < 0:
dy = -dy
x = [(float(centroid0.values[0]+centroid1.values[0]))/2-1.5*dx,(float(centroid0.values[0]+centroid1.values[0]))/2+1.5*dx]
y = [(float(centroid0.values[1]+centroid1.values[1]))/2-1.5*dy,(float(centroid0.values[1]+centroid1.values[1]))/2+1.5*dy]
#time to keep displayed
time = 4
plt.hold(True)
plt.plot(x,y,c='red',linewidth=3)
plt.waitforbuttonpress(timeout=time)
plt.savefig("output/fig.png")
开发者ID:g-soulie,项目名称:kmeans,代码行数:32,代码来源:es.py
示例4: draw_pivot_interactive
def draw_pivot_interactive(self, xk, key_pressed=False, wait_time=1):
"""Draw a red circle at the current pivot position.
To be used interactively.
Keyword Arguments:
xk -- a pair representing the position of the new pivot
key_pressed -- True if a key or button must be pressed to continue else
wait for time seconds
wait_time -- the time in seconds to wait
"""
if self.started:
if self.pivot_patch is None:
self.pivot_patch = plt.Circle((0, 0), 0.1, fc='r')
else:
gui_line, = self.ax.plot([self.pivot_patch.center[0], xk[0]],
[self.pivot_patch.center[1], xk[1]])
gui_line.set_color('red')
gui_line.set_linestyle('-')
gui_line.set_linewidth(3)
plt.draw()
self.pivot_patch.center = (xk[0], xk[1])
self.ax.add_patch(self.pivot_patch)
else:
self.started = True
if key_pressed:
plt.waitforbuttonpress()
else:
plt.pause(wait_time)
开发者ID:tofgarion,项目名称:lp-visu,代码行数:31,代码来源:lp_visu.py
示例5: waitForInput
def waitForInput():
''' This time, proceed with a click or by hitting any key '''
plt.plot(t,c)
plt.title('Click in that window, or hit any key to continue')
plt.waitforbuttonpress()
plt.close()
开发者ID:phaustin,项目名称:statsintro,代码行数:7,代码来源:interactivePlots.py
示例6: show_example
def show_example(out_path, counter, data_all):
"""
Show example - need to re-write every time we change the data
:param out_path: output writing path
:param counter: example number
:param data_all: dictionary with all data
"""
print "out_path: " + out_path
print "counter: " + str(counter)
fig, ax = plt.subplots(nrows=3, ncols=2)
fig.set_size_inches(18.5, 10.5, forward=True)
ax[0][0].set_title('Original Image')
imshow(data_all["image_gt"], ax=ax[0][0], fig=fig)
ax[0][1].set_title('SubSampled Image')
imshow(data_all["image"], ax=ax[0][1], fig=fig)
ax[1][0].set_title('Origianl real k-space')
imshow(data_all["k_space_real_gt"], ax=ax[1][0], fig=fig)
ax[1][1].set_title('SubSampled real k-space')
imshow(data_all["k_space_real"], ax=ax[1][1], fig=fig)
ax[2][0].set_title('Origianl imaginary k-space')
imshow(data_all["k_space_imag_gt"], ax=ax[2][0], fig=fig)
ax[2][1].set_title('SubSampled imaginary k-space')
imshow(data_all["k_space_imag"], ax=ax[2][1], fig=fig)
plt.waitforbuttonpress(timeout=-1)
plt.close()
开发者ID:shohad25,项目名称:thesis,代码行数:33,代码来源:data_creator.py
示例7: show_results
def show_results(data, labels):
"""
This is a utility function that can be used to visualize which
images end up in which class.
Parameters:
data - A set of images in the original data format
labels - one 0,1 label for each image.
"""
implot = None
for i in range(data.shape[0]):
if implot == None:
implot = plt.imshow(data_to_img(data[i,:]),
interpolation='none')
txt = plt.text(5, 5, str(labels[i]),size='20',
color=(0,1,0))
else:
implot.set_data(data_to_img(data[i,:]))
txt.set_text(str(labels[i]))
fig = plt.gcf()
fig.set_size_inches(2,2)
plt.xticks(())
plt.yticks(())
plt.draw()
plt.waitforbuttonpress()
开发者ID:AdityoSanjaya,项目名称:neural_rl,代码行数:26,代码来源:pa3util.py
示例8: interactive_fit
def interactive_fit(redshifts, vals, nchi2, templ, sp, outfile, filename,
fig, spec2d=None, wa2d=None, spec2dpos=None, msky=None):
fig.clf()
objname = filename.split('/')[-1].replace('_xcorr.sav', '')
wrapper = FindZWrapper(redshifts, vals, nchi2, templ, sp, objname, fig=fig,
spec2d=spec2d, wa2d=wa2d, spec2dpos=spec2dpos,
msky=msky)
# wait until user decides on redshift
try:
while wrapper.wait:
pl.waitforbuttonpress()
except (tkinter.TclError, KeyboardInterrupt):
print "\nClosing\n"
sys.exit(1)
if wrapper.zconf == 'k':
# skip
return
print filename
plotname = filename.replace('_xcorr.sav','.png')
print 'saving to ', plotname
fig.savefig(plotname)
outfile.write('%20s %10s % 8.5e %1s\n' % (
filename.split('/')[-1].split('_xcorr')[0], templ[wrapper.i].label,
wrapper.zgood, wrapper.zconf))
outfile.flush()
开发者ID:nhmc,项目名称:findz_VIMOS,代码行数:28,代码来源:findz_VIMOS_plot.py
示例9: plot_maps
def plot_maps(maps,coords,width,height):
import matplotlib.pyplot as plt;
maps=np.array(maps);
shape=maps.shape;
num_vert=1;
num_hor=len(maps);
if(len(shape)>2):
num_vert=shape[0];
num_hor=shape[1];
fig, axs=plt.subplots(num_vert,num_hor);
for j in range(num_vert):
for i in range(num_hor):
if(num_vert==1):
fig.colorbar(
axs[i].imshow(
mapnodestoimg(maps[i],width,
height,coords)),ax=axs[i]);
else:
fig.colorbar(
axs[j][i].imshow(
mapnodestoimg(maps[j][i],width,
height,coords)),ax=axs[j][i]);
fig.show();
plt.draw();
plt.waitforbuttonpress();
开发者ID:manic-milos,项目名称:Autoencoders,代码行数:26,代码来源:visualization.py
示例10: cut_bounds
def cut_bounds(self, data):
def tellme(s):
print s
plt.title(s,fontsize=16)
plt.draw()
plt.clf()
plt.plot(data)
plt.setp(plt.gca(),autoscale_on=False)
tellme('You will select start and end bounds. Click to continue')
plt.waitforbuttonpress()
happy = False
while not happy:
pts = []
while len(pts) < 2:
tellme('Select 2 bounding points with mouse')
pts = plt.ginput(2,timeout=-1)
if len(pts) < 2:
tellme('Too few points, starting over')
time.sleep(1) # Wait a second
plt.fill_between(x, y1, y2, alpha=0.5, facecolor='grey', interpolate=True)
tellme('Happy? Key click for yes, mouse click for no')
happy = plt.waitforbuttonpress()
bounds = sorted([int(i[0]) for i in pts])
plt.clf()
print bounds
return data[bounds[0] if bounds[0] > .02*len(data) else 0:bounds[1] if bounds[1] < len(data)-1 else len(data)-1],bounds
开发者ID:zlt298,项目名称:hcl_perdb,代码行数:33,代码来源:madgetech_2_rht.py
示例11: test_mnist
def test_mnist():
"""Summary
Returns
-------
name : TYPE
Description
"""
# %%
import tensorflow as tf
import tensorflow.examples.tutorials.mnist.input_data as input_data
import matplotlib.pyplot as plt
# %%
# load MNIST as before
mnist = input_data.read_data_sets('MNIST_data', one_hot=True)
mean_img = np.mean(mnist.train.images, axis=0)
ae = VAE()
# %%
learning_rate = 0.002
optimizer = tf.train.AdagradOptimizer(learning_rate).minimize(ae['cost'])
# %%
# We create a session to use the graph
sess = tf.Session()
sess.run(tf.initialize_all_variables())
# %%
# Fit all training data
batch_size = 100
n_epochs = 50
for epoch_i in range(n_epochs):
for batch_i in range(mnist.train.num_examples // batch_size):
batch_xs, _ = mnist.train.next_batch(batch_size)
train = np.array([(img - mean_img) for img in batch_xs])
print(epoch_i,
sess.run([ae['cost'], optimizer],
feed_dict={ae['x']: train})[0])
# %%
# Plot example reconstructions
n_examples = 12
test_xs, _ = mnist.test.next_batch(n_examples)
test_xs_norm = np.array([img - mean_img for img in test_xs])
recon = sess.run(ae['y'], feed_dict={ae['x']: test_xs_norm})
print(recon.shape)
fig, axs = plt.subplots(2, n_examples, figsize=(10, 2))
for example_i in range(n_examples):
axs[0][example_i].imshow(
np.reshape(test_xs[example_i, :], (28, 28)),
cmap='gray')
axs[1][example_i].imshow(
np.reshape(
np.reshape(recon[example_i, ...], (784,)) + mean_img,
(28, 28)),
cmap='gray')
fig.show()
plt.draw()
plt.waitforbuttonpress()
开发者ID:Prinsphield,项目名称:tensorflow_tutorials,代码行数:60,代码来源:X_variational_autoencoder.py
示例12: createHistogramOfOrientedGradientFeatures
def createHistogramOfOrientedGradientFeatures(sourceImage, numOrientations, pixelsPerCell):
# Returns an nxd matrix, n pixels and d the HOG vector length.
# H is a matrix NBLOCKS_Y x NBLOCKS_X x CPB_Y x CPB_X x ORIENTATIONS
# Here CPB == 1
H,Himg = myhog.hog( sourceImage, numOrientations, pixelsPerCell, cells_per_block=(1,1), flatten=False, visualise=True )
hog_image_rescaled = skimage.exposure.rescale_intensity( Himg )#, in_range=(0, 0.2))
plt.interactive(True)
plt.figure()
plt.subplot(1,2,1)
plt.imshow(sourceImage)
plt.subplot(1,2,2)
plt.imshow( hog_image_rescaled, cmap=plt.cm.gray )
plt.title('HOG')
plt.waitforbuttonpress()
# Reduce to non-singleton dimensions, BY x BX x ORIENT
H = H.squeeze()
assert H.ndim == 3
assert H.max() <= 1.0
# resize to image pixels rather than grid blocks
hogImg = np.zeros( ( sourceImage.shape[0], sourceImage.shape[1], numOrientations ), dtype=float )
for o in range(numOrientations):
hogPerOrient = H[:,:,o].astype(np.float32)
hpoAsPil = pil.fromarray( hogPerOrient, mode='F' )
hogImg[:,:,o] = np.array( hpoAsPil.resize( (sourceImage.shape[1], sourceImage.shape[0]), pil.NEAREST ) )
return hogImg.reshape( ( sourceImage.shape[0]*sourceImage.shape[1], numOrientations ) )
开发者ID:RockStarCoders,项目名称:alienMarkovNetworks,代码行数:27,代码来源:FeatureGenerator.py
示例13: debug_call
def debug_call(particles_weighted, the_map):
debug = False
if not debug:
return
# Initialize figure
my_dpi = 96
plt.figure(1, figsize=(800/my_dpi, 800/my_dpi), dpi=my_dpi)
plt.cla()
plt.xlim ( the_map.info.origin.position.x, the_map.info.origin.position.x + the_map.info.width )
plt.ylim ( the_map.info.origin.position.y, the_map.info.origin.position.y + the_map.info.height )
plt.gca().set_aspect('equal', adjustable='box')
plt.xlabel('X world')
plt.xlabel('Y world')
ax = plt.axes()
# Draw map
draw_occupancy_grid(the_map, ax)
# Draw particles
draw_particles_scored(particles_weighted)
# Show plot
plt.draw()
pause = True
if pause:
k = plt.waitforbuttonpress(1)
while not k:
k = plt.waitforbuttonpress(1)
else:
plt.waitforbuttonpress(1e-6)
开发者ID:chiragmajithia,项目名称:Particle_Filter,代码行数:34,代码来源:particle.py
示例14: replay
def replay():
data = pickle.load(open(fpkl, 'rb'))
for d in data:
ts = d['newdata']['ts']
spds = d['newdata']['spds']
dists = d['newdata']['dists']
coef_spd = d['fit_coef']['spd']
coef_dist = d['fit_coef']['dist']
tsp = np.linspace(0, ts[-1], 100)
pfspd = np.poly1d(coef_spd)
fspds = pfspd(tsp)
pfdist = np.poly1d(coef_dist)
fdists = pfdist(tsp)
print 'a: %f, %f' % (coef_dist[0] * 2, coef_spd[0])
plt.subplot(121)
plt.plot(ts, spds, '.', ms=10, color='b')
plt.plot(tsp, fspds, '-', color='b')
plt.plot(ts, dists, '.', ms=10, color='g')
plt.plot(tsp, fdists, '-', color='g')
plt.subplot(122)
plt.plot(ts, spds, '.')
plt.draw()
plt.waitforbuttonpress(-1)
plt.clf()
开发者ID:espinielli,项目名称:flight-data-processor,代码行数:32,代码来源:tap_takeoff.py
示例15: hanoi
def hanoi(n, A, B, C):
if n > 0:
hanoi(n - 1, A, C, B)
config[A].pop()
config[C].append(n)
plt.waitforbuttonpress()
plot_config(config)
hanoi(n - 1, B, A, C)
开发者ID:lgarcin,项目名称:TIPE,代码行数:8,代码来源:hanoi.py
示例16: display_unbounded
def display_unbounded(self):
tableau_latex = self.attain_tableau_latex()
unbounded_latex = r"""\noindent Unbounded!"""
unbounded_latex += r" \\"
self.text.set_text(unbounded_latex + tableau_latex)
plt.waitforbuttonpress()
plt.draw()
plt.waitforbuttonpress()
开发者ID:golmschenk,项目名称:simplex,代码行数:8,代码来源:display.py
示例17: photos
def photos(tt, tangl, tz0):
fig = plt.figure(num=0)
ax = fig.add_subplot(111)
for i in [0, 100, 200, 300, 400]:
ax.clear()
photo2(ax, tt[i], tangl[i], tz0[i])
plt.show()
plt.waitforbuttonpress(timeout=1)
开发者ID:gburgunder,项目名称:TIPE_pelamis,代码行数:8,代码来源:test2_mvt_pelamis_vague.py
示例18: draw_mars_data
def draw_mars_data(data):
u = np.unique(data.flatten())
u.sort()
print(u[0], u[1])
#print np.min(data), np.max(data)
data = np.clip(data, u[1], np.max(data))
imgplot = plt.imshow(data, interpolation="nearest")
plt.waitforbuttonpress()
开发者ID:FredrikNoren,项目名称:nn_mars,代码行数:8,代码来源:main.py
示例19: roipoly
def roipoly(ax=None):
""" use polygonmask to get the pixel mask"""
if ax is None:
ax = plt.gca()
r = Roipoly(ax)
while not r.done:
plt.waitforbuttonpress()
return r.verts
开发者ID:htlemke,项目名称:ixppy,代码行数:8,代码来源:toolsPlot.py
示例20: test_mnist
def test_mnist():
"""Test the convolutional autoencder using MNIST."""
# %%
import tensorflow as tf
import tensorflow.examples.tutorials.mnist.input_data as input_data
import matplotlib.pyplot as plt
flags = tf.app.flags
FLAGS = flags.FLAGS
flags.DEFINE_string('data_dir', '../data/mnist/', 'Directory for storing data')
# %%
# load MNIST as before
mnist = input_data.read_data_sets(FLAGS.data_dir, one_hot=True)
mean_img = np.mean(mnist.train.images, axis=0)
ae = autoencoder()
# %%
learning_rate = 0.01
optimizer = tf.train.AdamOptimizer(learning_rate).minimize(ae['cost'])
# %%
# We create a session to use the graph
sess = tf.Session()
sess.run(tf.initialize_all_variables())
# %%
# Fit all training data
batch_size = 100
n_epochs = 10
for epoch_i in range(n_epochs):
for batch_i in range(mnist.train.num_examples // batch_size):
batch_xs, _ = mnist.train.next_batch(batch_size)
train = np.array([img - mean_img for img in batch_xs])
sess.run(optimizer, feed_dict={ae['x']: train})
print(epoch_i, sess.run(ae['cost'], feed_dict={ae['x']: train}))
# %%
# Plot example reconstructions
n_examples = 10
test_xs, _ = mnist.test.next_batch(n_examples)
test_xs_norm = np.array([img - mean_img for img in test_xs])
recon = sess.run(ae['y'], feed_dict={ae['x']: test_xs_norm})
print(recon.shape)
fig, axs = plt.subplots(2, n_examples, figsize=(10, 2))
for example_i in range(n_examples):
axs[0][example_i].imshow(
np.reshape(test_xs[example_i, :], (28, 28)))
axs[1][example_i].imshow(
np.reshape(
np.reshape(recon[example_i, ...], (784,)) + mean_img,
(28, 28)))
fig.show()
plt.draw()
plt.waitforbuttonpress()
开发者ID:hoondori,项目名称:reproducible_machine_learning,代码行数:56,代码来源:mnist_by_conv_autoencoder.py
注:本文中的matplotlib.pyplot.waitforbuttonpress函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论