本文整理汇总了Python中matplotlib.pyplot.get_current_fig_manager方法的典型用法代码示例。如果您正苦于以下问题:Python pyplot.get_current_fig_manager方法的具体用法?Python pyplot.get_current_fig_manager怎么用?Python pyplot.get_current_fig_manager使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.pyplot
的用法示例。
在下文中一共展示了pyplot.get_current_fig_manager方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_root_locus_zoom
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import get_current_fig_manager [as 别名]
def test_root_locus_zoom(self):
"""Check the zooming functionality of the Root locus plot"""
system = TransferFunction([1000], [1, 25, 100, 0])
root_locus(system)
fig = plt.gcf()
ax_rlocus = fig.axes[0]
event = type('test', (object,), {'xdata': 14.7607954359, 'ydata': -35.6171379864, 'inaxes': ax_rlocus.axes})()
ax_rlocus.set_xlim((-10.813628105112421, 14.760795435937652))
ax_rlocus.set_ylim((-35.61713798641108, 33.879716621220311))
plt.get_current_fig_manager().toolbar.mode = 'zoom rect'
_RLClickDispatcher(event, system, fig, ax_rlocus, '-')
zoom_x = ax_rlocus.lines[-2].get_data()[0][0:5]
zoom_y = ax_rlocus.lines[-2].get_data()[1][0:5]
zoom_y = [abs(y) for y in zoom_y]
zoom_x_valid = [-5. ,- 4.61281263, - 4.16689986, - 4.04122642, - 3.90736502]
zoom_y_valid = [0. ,0., 0., 0., 0.]
assert_array_almost_equal(zoom_x,zoom_x_valid)
assert_array_almost_equal(zoom_y,zoom_y_valid)
示例2: _RLClickDispatcher
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import get_current_fig_manager [as 别名]
def _RLClickDispatcher(event, sys, fig, ax_rlocus, plotstr, sisotool=False,
bode_plot_params=None, tvect=None):
"""Rootlocus plot click dispatcher"""
# Zoom is handled by specialized callback above, only do gain plot
if event.inaxes == ax_rlocus.axes and \
plt.get_current_fig_manager().toolbar.mode not in \
{'zoom rect', 'pan/zoom'}:
# if a point is clicked on the rootlocus plot visually emphasize it
K = _RLFeedbackClicksPoint(event, sys, fig, ax_rlocus, sisotool)
if sisotool and K is not None:
_SisotoolUpdate(sys, fig, K, bode_plot_params, tvect)
# Update the canvas
fig.canvas.draw()
示例3: main
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import get_current_fig_manager [as 别名]
def main(args):
"""
Main function for the script
:param args: parsed command line arguments
:return: None
"""
img_file = os.path.join(args.image_path)
if args.npz_file:
img = np.load(img_file)
img = img.squeeze(0).transpose(1, 2, 0)
else:
img = np.array(Image.open(img_file))
# show the image on screen:
plt.figure().suptitle(args.image_path.split("/")[-1])
plt.imshow(img)
mng = plt.get_current_fig_manager()
mng.resize(*mng.window.maxsize())
plt.show()
示例4: main
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import get_current_fig_manager [as 别名]
def main(args):
"""
Main function for the script
:param args: parsed command line arguments
:return: None
"""
# go over the image files in the directory
for img_file_name in os.listdir(args.images_path):
img_file = os.path.join(args.images_path, img_file_name)
if args.npz_files:
img = np.load(img_file)
img = img.squeeze(0).transpose(1, 2, 0)
else:
img = np.array(Image.open(img_file))
# show the image on screen:
plt.figure().suptitle(img_file_name)
plt.imshow(img)
mng = plt.get_current_fig_manager()
mng.resize(*mng.window.maxsize())
plt.show()
示例5: visualize_stn
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import get_current_fig_manager [as 别名]
def visualize_stn(data, title):
input_tensor = data.cpu()
input_tensor = torch.squeeze(input_tensor)
input_tensor = input_tensor.detach().numpy()
N = len(input_tensor)
fig=plt.figure(num = 2)
columns = N
rows = 1
for i in range(1, columns*rows +1):
img = input_tensor[i-1]
fig.add_subplot(rows, columns, i)
plt.imshow(img, cmap='gray', interpolation='none')
figManager = plt.get_current_fig_manager()
figManager.resize(*figManager.window.maxsize())
# figManager.window.state('zoomed')
plt.show(block=False)
# time.sleep(4)
# plt.close()
示例6: show
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import get_current_fig_manager [as 别名]
def show(self, plot_config, block=True, maximize=False, window_title=None):
"""Show the data contained in this visualizer using the specifics in this function call.
Args:
plot_config (mdt.visualization.maps.base.MapPlotConfig): the plot configuration
block (boolean): If we want to block after calling the plots or not. Set this to False if you
do not want the routine to block after drawing. In doing so you manually need to block.
maximize (boolean): if we want to display the window maximized or not
window_title (str): the title of the window. If None, the default title is used
"""
Renderer(self._data_info, self._figure, plot_config).render()
if maximize:
mng = plt.get_current_fig_manager()
mng.window.showMaximized()
if window_title:
mng = plt.get_current_fig_manager()
mng.canvas.set_window_title(window_title)
if block:
plt.show(True)
示例7: show_pca
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import get_current_fig_manager [as 别名]
def show_pca(self, dest_image, updater):
colors = ['navy', 'turquoise', 'darkorange']
if getattr(updater, 'pca', None) is None:
return dest_image
pca_discriminator = updater.pca.reshape(3, -1, updater.n_components_pca)
plt.figure()
for i, color, in enumerate(colors):
plt.scatter(pca_discriminator[i, :, 0], pca_discriminator[i, :, 1], color=color, lw=2)
plt.legend(['fake', 'real', 'anchor'])
canvas = plt.get_current_fig_manager().canvas
canvas.draw()
image = Image.frombytes('RGB', canvas.get_width_height(), canvas.tostring_rgb())
image = image.resize((self.image_size.width, self.image_size.height), Image.LANCZOS)
dest_image.paste(image, (self.image_size.width, self.image_size.height))
plt.close()
return dest_image
示例8: show
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import get_current_fig_manager [as 别名]
def show(pts, cells, geo, title=None, full_screen=True):
import matplotlib.pyplot as plt
eps = 1.0e-10
is_inside = geo.dist(pts.T) < eps
plt.plot(pts[is_inside, 0], pts[is_inside, 1], ".")
plt.plot(pts[~is_inside, 0], pts[~is_inside, 1], ".", color="r")
plt.triplot(pts[:, 0], pts[:, 1], cells)
plt.axis("square")
if full_screen:
figManager = plt.get_current_fig_manager()
try:
figManager.window.showMaximized()
except AttributeError:
# Some backends have no window (e.g., Agg)
pass
if title is not None:
plt.title(title)
try:
geo.show(level_set=False)
except AttributeError:
pass
示例9: export_all_contours
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import get_current_fig_manager [as 别名]
def export_all_contours(contours, img_path):
counter_img = 0
counter_label = 0
batchsz = 100
print("Processing {:d} images and labels...".format(len(contours)))
for i, ctr in enumerate(contours):
img, label = load_contour(ctr, img_path)
images.append(img)
labels.append(label)
#print ctr
#if "SC-HYP-12" in ctr.__str__():
#pass
"""
if i>-1:
plt.figure()
mngr = plt.get_current_fig_manager()
# to put it into the upper left corner for example:
mngr.window.setGeometry(50, 100, 640, 545)
plt.suptitle(ctr.__str__() + " #%d" % i)
plt.imshow(img * (1-label) + (np.max(img)-img)*(label) )
#plt.imshow(label)
plt.show()
"""
示例10: animate_slice
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import get_current_fig_manager [as 别名]
def animate_slice(slicedata1, slicedata2, index1, index2):
fig, (ax1, ax2) = plt.subplots(1, 2)
mngr = plt.get_current_fig_manager()
# to put it into the upper left corner for example:
mngr.window.setGeometry(50, 100, 600, 300)
im1 = ax1.imshow(slicedata1[0], cmap='gist_gray_r')
im2 = ax2.imshow(slicedata2[0], cmap='gist_gray_r')
fig.suptitle('patient %d vs %d' % (index1, index2))
def init():
im1.set_data(slicedata1[0])
im2.set_data(slicedata2[0])
def animate(i):
im1.set_data(slicedata1[i])
im2.set_data(slicedata2[i])
return im1
anim = animation.FuncAnimation(fig, animate, init_func=init, frames=len(slicedata1), interval=50)
plt.show()
示例11: prepare
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import get_current_fig_manager [as 别名]
def prepare(self):
if self.backend:
plt.switch_backend(self.backend)
self.f = plt.figure(figsize=self.window_size)
self.ax = self.f.add_subplot(111)
self.lines = []
for _ in self.labels:
if self.interp:
self.lines.append(self.ax.plot([], [])[0])
else:
self.lines.append(self.ax.step([], [])[0])
# Keep only 1/factor points on each line
self.factor = [1 for i in self.labels]
# Count to drop exactly 1/factor points, no more and no less
self.counter = [0 for i in self.labels]
legend = [y for x, y in self.labels]
plt.legend(legend, bbox_to_anchor=(-0.03, 1.02, 1.06, .102), loc=3,
ncol=len(legend), mode="expand", borderaxespad=1)
plt.xlabel(self.labels[0][0])
plt.ylabel(self.labels[0][1])
plt.grid()
self.axclear = plt.axes([.8,.02,.15,.05])
self.bclear = Button(self.axclear,'Clear')
self.bclear.on_clicked(self.clear)
if self.window_pos:
mng = plt.get_current_fig_manager()
mng.window.wm_geometry("+%s+%s" % self.window_pos)
plt.draw()
plt.pause(.001)
示例12: visualize
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import get_current_fig_manager [as 别名]
def visualize(data, fig_num, title):
input_tensor = data.cpu()
input_tensor = torch.squeeze(input_tensor)
in_grid = input_tensor.detach().numpy()
fig=plt.figure(num = fig_num)
plt.imshow(in_grid, cmap='gray', interpolation='none')
plt.title(title)
figManager = plt.get_current_fig_manager()
figManager.resize(*figManager.window.maxsize())
plt.show(block=False)
# time.sleep(4)
# plt.close()
示例13: forSecond
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import get_current_fig_manager [as 别名]
def forSecond(frame_number, output_arrays, count_arrays, average_count, returned_frame):
plt.clf()
this_colors = []
labels = []
sizes = []
counter = 0
for eachItem in average_count:
counter += 1
labels.append(eachItem + " = " + str(average_count[eachItem]))
sizes.append(average_count[eachItem])
this_colors.append(color_index[eachItem])
global resized
if (resized == False):
manager = plt.get_current_fig_manager()
manager.resize(width=1000, height=500)
resized = True
plt.subplot(1, 2, 1)
plt.title("Second : " + str(frame_number))
plt.axis("off")
plt.imshow(returned_frame, interpolation="none")
plt.subplot(1, 2, 2)
plt.title("Analysis: " + str(frame_number))
plt.pie(sizes, labels=labels, colors=this_colors, shadow=True, startangle=140, autopct="%1.1f%%")
plt.pause(0.01)
示例14: forFrame
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import get_current_fig_manager [as 别名]
def forFrame(frame_number, output_array, output_count, returned_frame):
plt.clf()
this_colors = []
labels = []
sizes = []
counter = 0
for eachItem in output_count:
counter += 1
labels.append(eachItem + " = " + str(output_count[eachItem]))
sizes.append(output_count[eachItem])
this_colors.append(color_index[eachItem])
global resized
if (resized == False):
manager = plt.get_current_fig_manager()
manager.resize(width=1000, height=500)
resized = True
plt.subplot(1, 2, 1)
plt.title("Frame : " + str(frame_number))
plt.axis("off")
plt.imshow(returned_frame, interpolation="none")
plt.subplot(1, 2, 2)
plt.title("Analysis: " + str(frame_number))
plt.pie(sizes, labels=labels, colors=this_colors, shadow=True, startangle=140, autopct="%1.1f%%")
plt.pause(0.01)
示例15: showMaximize
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import get_current_fig_manager [as 别名]
def showMaximize():
mng = plt.get_current_fig_manager()
mng.window.state('zoomed')
plt.show()