本文整理汇总了Python中matplotlib.pyplot.waitforbuttonpress方法的典型用法代码示例。如果您正苦于以下问题:Python pyplot.waitforbuttonpress方法的具体用法?Python pyplot.waitforbuttonpress怎么用?Python pyplot.waitforbuttonpress使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.pyplot
的用法示例。
在下文中一共展示了pyplot.waitforbuttonpress方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: explore_random_examples
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import waitforbuttonpress [as 别名]
def explore_random_examples(self, dataset_split):
"""
Visualize random examples for dataset exploration purposes
Parameters
----------
dataset_split: str
Dataset split, can be either 'train' or 'test'
Returns
-------
None
"""
if self.initialized:
subplots = plt.subplots(nrows=1, ncols=2)
for i in np.random.permutation(SmallNORBDataset.n_examples):
self.data[dataset_split][i].show(subplots)
plt.waitforbuttonpress()
plt.cla()
示例2: drawing_loop
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import waitforbuttonpress [as 别名]
def drawing_loop(self, drawing_pipe):
# start the matplotlib plotting
self.init_ui()
while self.running.is_set():
exec_time = time()
# get any data from the polling loop
updts = None
while drawing_pipe.poll():
data_from_plant = drawing_pipe.recv()
if data_from_plant is None:
self.running.clear()
break
# get the visuzlization updates from the latest state
state, t = data_from_plant
updts = self.update(state, t)
self.update_canvas(updts)
# sleep to guarantee the desired frame rate
exec_time = time() - exec_time
plt.waitforbuttonpress(max(self.dt-exec_time, 1e-9))
self.close()
示例3: visualize
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import waitforbuttonpress [as 别名]
def visualize(dom, states_xy, pred_traj):
fig, ax = plt.subplots()
implot = plt.imshow(dom, cmap="Greys_r")
ax.plot(states_xy[:, 0], states_xy[:, 1], c='b', label='Optimal Path')
ax.plot(
pred_traj[:, 0], pred_traj[:, 1], '-X', c='r', label='Predicted Path')
ax.plot(states_xy[0, 0], states_xy[0, 1], '-o', label='Start')
ax.plot(states_xy[-1, 0], states_xy[-1, 1], '-s', label='Goal')
legend = ax.legend(loc='upper right', shadow=False)
for label in legend.get_texts():
label.set_fontsize('x-small') # the legend text size
for label in legend.get_lines():
label.set_linewidth(0.5) # the legend line width
plt.draw()
plt.waitforbuttonpress(0)
plt.close(fig)
示例4: demo_cmd
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import waitforbuttonpress [as 别名]
def demo_cmd(description="load and align images in a directory",
path=None, frame=5, grid=(3, 10), tform=AffineTransform):
"""load and align images in a directory, animating the process
Parameters
----------
see rasl_arg_parser
"""
parser = rasl_arg_parser(description=description, path=path, frame=frame,
grid=grid, tform=tform)
args = parser.parse_args()
Image = load_images(args.path)
if len(Image) < np.prod(args.grid):
raise ValueError("Only {} images, specify a smaller --grid than {}"\
.format(len(Image), args.grid))
T = [args.tform().inset(image.shape, args.frame)
for image in Image]
_ = rasl(Image, T, stop_delta=args.stop, show=args.grid)
print("click the image to exit")
plt.waitforbuttonpress()
示例5: sitk_show
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import waitforbuttonpress [as 别名]
def sitk_show(nda, title=None, margin=0.0, dpi=40):
figsize = (1 + margin) * nda.shape[0] / dpi, (1 + margin) * nda.shape[1] / dpi
extent = (0, nda.shape[1], nda.shape[0], 0)
fig = plt.figure(figsize=figsize, dpi=dpi)
ax = fig.add_axes([margin, margin, 1 - 2*margin, 1 - 2*margin])
plt.set_cmap("gray")
for k in range(0,nda.shape[2]):
print "printing slice "+str(k)
ax.imshow(np.squeeze(nda[:,:,k]),extent=extent,interpolation=None)
plt.draw()
plt.pause(0.1)
#plt.waitforbuttonpress()
示例6: imshow
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import waitforbuttonpress [as 别名]
def imshow(inps, title=None):
"""Imshow for Tensor."""
subwindows = len(inps)
for idx, (inp, name) in enumerate(zip(inps, title)):
inp = inp.numpy().transpose((1, 2, 0))
ax = plt.subplot(1, subwindows, idx+1)
ax.axis('off')
plt.imshow(inp)
ax.set_title(name)
# plt.pause(0.001)
plt.show()
# plt.waitforbuttonpress(-1)
示例7: update_canvas
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import waitforbuttonpress [as 别名]
def update_canvas(self, updts):
if updts is not None:
# update the drawing from the plant state
self.fig.canvas.restore_region(self.bg)
for artist in updts:
self.ax.draw_artist(artist)
self.fig.canvas.update()
# sleep to guarantee the desired frame rate
exec_time = time() - self.exec_time
plt.waitforbuttonpress(max(self.dt-exec_time, 1e-9))
self.exec_time = time()
示例8: sitk_show
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import waitforbuttonpress [as 别名]
def sitk_show(nda, title=None, margin=0.0, dpi=40):
figsize = (1 + margin) * nda.shape[0] / dpi, (1 + margin) * nda.shape[1] / dpi
extent = (0, nda.shape[1], nda.shape[0], 0)
fig = plt.figure(figsize=figsize, dpi=dpi)
ax = fig.add_axes([margin, margin, 1 - 2*margin, 1 - 2*margin])
plt.set_cmap("gray")
for k in range(0,nda.shape[2]):
print ("printing slice "+str(k))
ax.imshow(np.squeeze(nda[:,:,k]),extent=extent,interpolation=None)
plt.draw()
plt.pause(0.1)
#plt.waitforbuttonpress()
开发者ID:mahendrakhened,项目名称:Automated-Cardiac-Segmentation-and-Disease-Diagnosis,代码行数:16,代码来源:test_utils.py
示例9: show_data_info
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import waitforbuttonpress [as 别名]
def show_data_info(self):
print("训练样本数:%s" % str(self.sample_amount))
print("训练集输入值行列数:%s" % str(self.train_X.shape))
print("训练集输出值行列数:%s" % str(self.train_Y.shape))
print("分类种类数:%s" % str(self.classification.shape))
self.sample_amount
plt.imshow(self.train_X[0]) # 非猫示例
# plt.waitforbuttonpress()
plt.imshow(self.train_X[27]) # 猫示例
# plt.waitforbuttonpress()
return self
示例10: visualize
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import waitforbuttonpress [as 别名]
def visualize(self, image, state, segmentation=None):
self.ax.cla()
self.ax.imshow(image)
if segmentation is not None:
self.ax.imshow(segmentation, alpha=0.5)
if isinstance(state, (OrderedDict, dict)):
boxes = [v for k, v in state.items()]
else:
boxes = (state,)
for i, box in enumerate(boxes, start=1):
col = _tracker_disp_colors[i]
col = [float(c) / 255.0 for c in col]
rect = patches.Rectangle((box[0], box[1]), box[2], box[3], linewidth=1, edgecolor=col, facecolor='none')
self.ax.add_patch(rect)
if getattr(self, 'gt_state', None) is not None:
gt_state = self.gt_state
rect = patches.Rectangle((gt_state[0], gt_state[1]), gt_state[2], gt_state[3], linewidth=1, edgecolor='g', facecolor='none')
self.ax.add_patch(rect)
self.ax.set_axis_off()
self.ax.axis('equal')
draw_figure(self.fig)
if self.pause_mode:
keypress = False
while not keypress:
keypress = plt.waitforbuttonpress()
示例11: hold_plot
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import waitforbuttonpress [as 别名]
def hold_plot():
print('Press any key to exit...')
plt.ioff()
plt.waitforbuttonpress()
plt.close()
示例12: waitforbuttonpress
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import waitforbuttonpress [as 别名]
def waitforbuttonpress():
plt.waitforbuttonpress(timeout=1)
示例13: plot_single
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import waitforbuttonpress [as 别名]
def plot_single(img, title=''):
plt.figure()
plt.title(title)
plt.imshow(img, cmap='gray')
plt.waitforbuttonpress()
示例14: plot_multiple
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import waitforbuttonpress [as 别名]
def plot_multiple(imgs, main_title='', titles=''):
num_img = len(imgs)
rows = (num_img + 1) / 2
plt.figure()
plt.title(main_title)
f, axarr = plt.subplots(rows, 2)
for i, (img, title) in enumerate(zip(imgs, titles)):
axarr[i/2, i%2].imshow(img.astype(np.uint8), cmap='gray')
axarr[i/2, i%2].set_title(title)
plt.waitforbuttonpress()
示例15: draw_rec_prec
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import waitforbuttonpress [as 别名]
def draw_rec_prec(rec, prec, mrec, mprec, class_name, ap):
"""
Draw plot
"""
plt.plot(rec, prec, '-o')
# add a new penultimate point to the list (mrec[-2], 0.0)
# since the last line segment (and respective area) do not affect the AP value
area_under_curve_x = mrec[:-1] + [mrec[-2]] + [mrec[-1]]
area_under_curve_y = mprec[:-1] + [0.0] + [mprec[-1]]
plt.fill_between(area_under_curve_x, 0, area_under_curve_y, alpha=0.2, edgecolor='r')
# set window title
fig = plt.gcf() # gcf - get current figure
fig.canvas.set_window_title('AP ' + class_name)
# set plot title
plt.title('class: ' + class_name + ' AP = {}%'.format(ap*100))
#plt.suptitle('This is a somewhat long figure title', fontsize=16)
# set axis titles
plt.xlabel('Recall')
plt.ylabel('Precision')
# optional - set axes
axes = plt.gca() # gca - get current axes
axes.set_xlim([0.0,1.0])
axes.set_ylim([0.0,1.05]) # .05 to give some extra space
# Alternative option -> wait for button to be pressed
#while not plt.waitforbuttonpress(): pass # wait for key display
# Alternative option -> normal display
#plt.show()
# save the plot
rec_prec_plot_path = os.path.join('result','classes')
os.makedirs(rec_prec_plot_path, exist_ok=True)
fig.savefig(os.path.join(rec_prec_plot_path, class_name + ".png"))
plt.cla() # clear axes for next plot