Python matplotlib.pyplot 模块,get_current_fig_manager() 实例源码

我们从Python开源项目中,提取了以下23个代码示例,用于说明如何使用matplotlib.pyplot.get_current_fig_manager()

项目:auckland-ai-meetup-x-triage    作者:a-i-joe    | 项目源码 | 文件源码
def plot_network(image, model, label=None):
    layer_names = [l.name for l in model.layers if isinstance(l,Conv2D)]
    n_conv = len(layer_names)
    n_axes = n_conv 
    prediction = model.predict(np.expand_dims(image,0))
    mng = plt.get_current_fig_manager()
    mng.full_screen_toggle()
    fig, [axlist1, axlist2] = plt.subplots(2,n_conv)
    diagnosis = ["negative", "positive"]
    for j in range(n_conv):
        plot_heatmap(image, model, layer_names[j],"abnormal",axlist1[j])
#        axlist1[j].set_xlabel(layer_names[j] + "ab")
    for j in range(n_conv):
        plot_heatmap(image, model, layer_names[j],"normal",axlist2[j],cmap=plt.cm.inferno)
    fig.suptitle("Prediction: {},  {}".format(prediction,label))
    fig.show()
项目:SLAPP3    作者:terna    | 项目源码 | 文件源码
def createGraph():
    global colors, pos

    # common.g=nx.DiGraph() # directed graph, instead of nx.Graph()
    common.g = nx.Graph()  # undirected, for oligopoly project
    colors = {}
    pos = {}
    common.g_labels = {}
    common.g_edge_labels = {}  # copy the address of the labels of the edges

    # setting Figure 1 (the switch of the control between Figure 1 and Figure 2
    # is managed in oActions.py

    if not common.IPython or common.graphicStatus == "PythonViaTerminal":
        # the or is about ipython running in a terminal
        plt.figure(1)
        mngr1 = plt.get_current_fig_manager()  # NB, after figure()
        mngr1.window.wm_geometry("+650+0")
        mngr1.set_window_title("Links Entrepreneurs - Workers")


# searching tools
项目:MDT    作者:cbclab    | 项目源码 | 文件源码
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)
项目:Simulator    作者:libsmelt    | 项目源码 | 文件源码
def draw_loop():
    """
    Draw the graph in a loop

    """
    global G

    plt.ion()

    # mng = plt.get_current_fig_manager()
    # mng.resize(*mng.window.maxsize())
    plt.draw()

    for line in fileinput.input():
        if output(line):
            plt.clf()
            nx.draw(G)
            plt.draw()
项目:aRMSD    作者:armsd    | 项目源码 | 文件源码
def plot(self):
        """ Plots result """

        mng = plt.get_current_fig_manager()  # Open directly in full window

        if mpl.get_backend() == 'Qt4Agg':  # 'Qt4' backend

            mng.window.showMaximized()

        elif mpl.get_backend() == 'WxAgg':  # 'WxAgg' backend

            mng.frame.Maximize(True)

        elif mpl.get_backend() == 'TKAgg':  # 'TKAgg' backend

            mng.frame.Maximize(True)

        plt.show(all)  # Show all plots
项目:pymoku    作者:liquidinstruments    | 项目源码 | 文件源码
def phase1_plot_setup():
    # Set up a 1x2 plot
    f, (ax1, ax2) = plt.subplots(1,2)
    f.suptitle('Phase 1 - Rise Times', fontsize=18, fontweight='bold')

    # Choose a colour palette and font size/style
    colours = sns.color_palette("muted")
    sns.set_context('poster')

    # Maximise the plotting window
    plot_backend = matplotlib.get_backend()
    mng = plt.get_current_fig_manager()
    if plot_backend == 'TkAgg':
        mng.resize(*mng.window.maxsize())
    elif plot_backend == 'wxAgg':
        mng.frame.Maximize(True)
    elif plot_backend == 'Qt4Agg':
        mng.window.showMaximized()

    return f, ax1, ax2
项目:pymoku    作者:liquidinstruments    | 项目源码 | 文件源码
def phase2_plot_setup():
    # Set up a 1x1 plot
    f, ax1 = plt.subplots(1,1)
    f.suptitle('Phase 2 - Line Width', fontsize=18, fontweight='bold')

    # Choose a colour palette and font size/style
    colours = sns.color_palette("muted")
    sns.set_context('poster')

    # Maximise the plotting window
    plot_backend = matplotlib.get_backend()
    mng = plt.get_current_fig_manager()
    if plot_backend == 'TkAgg':
        mng.resize(*mng.window.maxsize())
    elif plot_backend == 'wxAgg':
        mng.frame.Maximize(True)
    elif plot_backend == 'Qt4Agg':
        mng.window.showMaximized()

    return f, ax1
项目:circletracking    作者:caspervdw    | 项目源码 | 文件源码
def plot_fits_for_user_confirmation(self, image):
        """
        Ask user to check if all fits are correct.
        Clicking on a fit removes it from the results.
        """
        _imshow_style = dict(origin='lower', interpolation='none',
                             cmap=plt.cm.gray)
        fig_manager = plt.get_current_fig_manager()
        fig_manager.window.showMaximized()
        plt.clf()
        plt.cla()
        plt.imshow(image, **_imshow_style)
        for i in UserCheckFits.stored_fits.index:
            circle = plt.Circle((UserCheckFits.stored_fits.loc[i].x,
                                 UserCheckFits.stored_fits.loc[i].y),
                                radius=UserCheckFits.stored_fits.loc[i].r,
                                fc='None', ec='b', ls='solid',
                                lw=0.3, label=i)

            # Enable picking
            circle.set_picker(10)

            plt.gca().add_patch(circle)

            plt.gca().annotate(i, (UserCheckFits.stored_fits.loc[i].x,
                                   UserCheckFits.stored_fits.loc[i].y),
                               color='b', weight='normal', size=8,
                               ha='center', va='center')
            plt.gca().set_title('Please check the result.'
                                + ' Click on a circle to toggle removal.'
                                + ' Close to confirm.')
            plt.gcf().canvas.mpl_connect('pick_event', self.on_pick)
        plt.show(block=True)
项目:Pytorch-Sketch-RNN    作者:alexis-jacq    | 项目源码 | 文件源码
def make_image(sequence, epoch, name='_output_'):
    """plot drawing with separated strokes"""
    strokes = np.split(sequence, np.where(sequence[:,2]>0)[0]+1)
    fig = plt.figure()
    ax1 = fig.add_subplot(111)
    for s in strokes:
        plt.plot(s[:,0],-s[:,1])
    canvas = plt.get_current_fig_manager().canvas
    canvas.draw()
    pil_image = PIL.Image.frombytes('RGB', canvas.get_width_height(),
                 canvas.tostring_rgb())
    name = str(epoch)+name+'.jpg'
    pil_image.save(name,"JPEG")
    plt.close("all")
项目:BRITE-data-reduction-tool    作者:Ashoka42    | 项目源码 | 文件源码
def on_press(self, event):
        # At first gets the toolbar-button-pressed-info and checks if
        # no toolbar-button is pressed (zooming or shifting/moving)
        # So zooming/shifting can be done without drawing a new rectangle
        toolbar = plt.get_current_fig_manager().toolbar
        if toolbar.mode == '':
            # If the mouse is INSIDE the plot
            if event.inaxes is self.ax1:
                # Enables drawing
                self.draw = 1
                # Gets the y-coordinate, where the mouse it located
                self.y0 = event.ydata

    # On mouse button release
项目:BRITE-data-reduction-tool    作者:Ashoka42    | 项目源码 | 文件源码
def on_press(self, event):
        # If not the left mouse-button is clicked
        if event.button != 1:
            return
        # At first gets the toolbar-button-pressed-info and checks if
        # no toolbar-button is pressed (zooming or shifting/moving)
        # So zooming/shifting can be done without drawing a new rectangle
        toolbar = plt.get_current_fig_manager().toolbar
        if toolbar.mode == '':

            # If the mouse is INSIDE the first plot
            if event.inaxes is self.ax1:
                # Enables drawing
                self.draw = 1
                # Gets the coordinates, where the mouse it located
                self.x0 = event.xdata
                self.y0 = event.ydata

            # If mouse in second plot
            if event.inaxes is self.ax2:
                # Enables drawing just of the x-coord (y=mag is static)
                self.draw = 1
                self.x0 = event.xdata

            if event.inaxes is self.ax3:
                # Enables drawing just of the x-coord (y=mag is static)
                # This x-value of this graph is the actual y-center-value
                self.draw = 1
                self.y0 = event.xdata

    # On mouse button release
项目:BRITE-data-reduction-tool    作者:Ashoka42    | 项目源码 | 文件源码
def on_press(self, event):
        # If not the left mouse-button is clicked
        if event.button != 1:
            return
        # At first gets the toolbar-button-pressed-info and checks if
        # no toolbar-button is pressed (zooming or shifting/moving)
        # So zooming/shifting can be done without drawing a new rectangle
        toolbar = plt.get_current_fig_manager().toolbar
        if toolbar.mode == '':

            # If the mouse is INSIDE the first plot
            if event.inaxes is self.ax1:
                # Enables drawing
                self.draw = 1
                # Gets the coordinates, where the mouse it located
                self.x0 = event.xdata
                self.y0 = event.ydata

            # If mouse in second plot
            if event.inaxes is self.ax2:
                # Enables drawing just of the x-coord (y=mag is static)
                self.draw = 1
                self.x0 = event.xdata

            if event.inaxes is self.ax3:
                # Enables drawing just of the x-coord (y=mag is static)
                # This x-value of this graph is the actual y-center-value
                self.draw = 1
                self.y0 = event.xdata

    # On mouse button release
项目:hand_eye_calibration    作者:ethz-asl    | 项目源码 | 文件源码
def plot_alignment_errors(errors_position, rmse_pose, errors_orientation,
                          rmse_orientation, blocking=True):
  assert np.array_equal(errors_position.shape, errors_orientation.shape)

  num_error_values = errors_position.shape[0]

  title_position = 1.05
  fig = plt.figure()
  a1 = fig.add_subplot(2, 1, 1)
  fig.suptitle("Alignment Evaluation", fontsize='24')
  a1.set_title(
      "Red = Position Error Norm [m] - Black = RMSE", y=title_position)
  plt.plot(errors_position, c='r')
  plt.plot(rmse_pose * np.ones((num_error_values, 1)), c='k')
  a2 = fig.add_subplot(2, 1, 2)
  a2.set_title(
      "Red = Absolute Orientation Error [Degrees] - Black = RMSE", y=title_position)
  plt.plot(errors_orientation, c='r')
  plt.plot(rmse_orientation * np.ones((num_error_values, 1)), c='k')
  if plt.get_backend() == 'TkAgg':
    mng = plt.get_current_fig_manager()
    max_size = mng.window.maxsize()
    max_size = (max_size[0], max_size[1] * 0.45)
    mng.resize(*max_size)
  fig.tight_layout()
  plt.subplots_adjust(left=0.025, right=0.975, top=0.8, bottom=0.05)
  plt.show(block=blocking)
项目:SLAPP3    作者:terna    | 项目源码 | 文件源码
def setAttr(x,y,title):
       #x and y are integer numbers; title a string
       mngr=plt.get_current_fig_manager()
       mngr.window.wm_geometry("+"+str(x)+"+"+str(y))
       mngr.set_window_title(title)

 #----------------------------------------
 # running in a Python IDE (recognized: IDLE or Spyder)
项目:goodman    作者:soar-telescope    | 项目源码 | 文件源码
def __call__(self, in_file, save=False):

        self.file = in_file
        self.fig, self.ax = plt.subplots()

        # read data and get its wavelength solution
        ccd = CCDData.read(self.file, unit=u.adu)
        wcs_reader = ReadWavelengthSolution(header=ccd.header,
                                            data=ccd.data)
        wavelength, intensity = wcs_reader()


        manager = plt.get_current_fig_manager()
        manager.window.showMaximized()
        plt.title('{:s}\n{:s}'.format(self.file, ccd.header['OBJECT']))

        self.ax.plot(wavelength, intensity, color='k', label='Data')
        self.ax.axvline(6562.8, color='r')
        self.ax.set_xlim((wavelength[0], wavelength[-1]))
        self.ax.set_ylabel('Intensity (ADU)')
        self.ax.set_xlabel('Wavelength (Angstrom)')

        plt.legend(loc='best')
        plt.subplots_adjust(left=0.05,
                            right=0.99,
                            top=0.96,
                            bottom=0.04,
                            hspace=0.17,
                            wspace=0.11)
        # plt.tight_layout()

        if not save:
            self.fig.canvas.mpl_connect('key_press_event', self.key_pressed)
            plt.show()
        # else:
        #     output = re.sub('.fits', '.png', self.file)
        #     plt.savefig(output, dpi=600)
项目:laser-detection-annotator    作者:lucasb-eyer    | 项目源码 | 文件源码
def _ignore(self, e):
        # https://scipy.github.io/old-wiki/pages/Cookbook/Matplotlib/Interactive_Plotting.html#Handling_click_events_while_zoomed
        # But we don't do `not e.inaxes` because that one is only set when the mouse moves, meaning
        # when we switch the frame, it will not be `inaxes` as long as we don't move the mouse!
        return plt.get_current_fig_manager().toolbar.mode != ''


# Annoyingly large amount of code for just a circle around the mouse cursor!
项目:deep_heart_hackatho    作者:akshaynathr    | 项目源码 | 文件源码
def __init__(self, *args, **kwargs):
        super(NuPICPlotOutput, self).__init__(*args, **kwargs)
        # Turn matplotlib interactive mode on.
        plt.ion()
        self.dates = []
        self.convertedDates = []
        self.value = []
        self.rawValue = []
        self.allValues = []
        self.allRawValues = []
        self.predicted = []
        self.anomalyScore = []
        self.anomalyLikelihood = []
        self.actualLine = None
        self.rawLine = None
        self.predictedLine = None
        self.anomalyScoreLine = None
        self.anomalyLikelihoodLine = None
        self.linesInitialized = False
        self._chartHighlights = []
        fig = plt.figure(figsize=(16, 10))
        gs = gridspec.GridSpec(2, 1, height_ratios=[3,    1])

        self._mainGraph = fig.add_subplot(gs[0, 0])
        plt.title(self.name)
        plt.ylabel('Value')
        plt.xlabel('Date')

        self._anomalyGraph = fig.add_subplot(gs[1])

        plt.ylabel('Percentage')
        plt.xlabel('Date')

        # Maximizes window
        mng = plt.get_current_fig_manager()
        mng.resize(800, 600)

        plt.tight_layout()
项目:MDT    作者:cbclab    | 项目源码 | 文件源码
def show(self, voxel_ind=0, names=None, maps_to_show=None, to_file=None, block=True, maximize=False,
             show_trace=True, nmr_bins=20, window_title=None, show_sliders=True, fit_gaussian=True,
             figure_options=None, sample_indices=None):
        """Show the samples per voxel.

        Args:
            voxel_ind (int): the voxel to show the samples from.
            names (dict): A list of names for the different maps. Use as ``{map_name: display_name}`` that is,
                 the key is the name of the map in the volumes dictionary and the display name is the string that will
                 be used as title for that map.
            maps_to_show (:class:`list`): A list of maps to show.
                The items in this list must correspond to the keys in the volumes dictionary.
            to_file (string, optional, default None): If to_file is not None it is supposed
                to be a filename where the image will be saved.
                If not set to None, nothing will be displayed, the results will directly be saved.
                Already existing items will be overwritten.
            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
            show_trace (boolean): if we show the trace of each map or not
            nmr_bins (dict or int): either a single value or one per map name
            show_sliders (boolean): if we show the slider or not
            fit_gaussian (boolean): if we fit and show a normal distribution (Gaussian) to the histogram or not
            window_title (str): the title of the window. If None, the default title is used
            figure_options (dict) options for the figure
            sample_indices (list): the list of sample indices to use
        """
        figure_options = figure_options or {'figsize': (18, 16)}
        self._figure = plt.figure(**figure_options)

        if names:
            self.names = names
        if maps_to_show:
            self.maps_to_show = maps_to_show
        self.voxel_ind = voxel_ind
        self._nmr_bins = nmr_bins or self._nmr_bins
        self._show_trace = show_trace
        self.show_sliders = show_sliders
        self._fit_gaussian = fit_gaussian
        self._sample_indices = sample_indices
        self._setup()

        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 to_file:
            plt.savefig(to_file)
            plt.close()
        else:
            plt.draw()
            if block:
                plt.show(True)
项目:goodman    作者:soar-telescope    | 项目源码 | 文件源码
def __init__(self, reference_dir):
        self.cleaned_list = []


        reference_data = ReferenceData(reference_dir)

        file_list = glob.glob(os.path.join(reference_dir, '*fits'))

        for lfile in file_list:
            self.fig, self.ax = plt.subplots()
            ccd = CCDData.read(lfile, unit=u.adu)
            read_wavelength = ReadWavelengthSolution(ccd.header, ccd.data)
            wavelength, intensity = read_wavelength()

            self.line_list = reference_data.get_line_list_by_name(
                ccd.header['OBJECT'])

            file_name = lfile.split('/')[-1]
            pickle_file_name = re.sub('.fits', '_list.pkl', file_name)

            manager = plt.get_current_fig_manager()
            manager.window.showMaximized()
            if os.path.isfile(pickle_file_name):
                with open(pickle_file_name, 'rb') as pickled_file:
                    line_list = pickle.load(pickled_file)
                    for ref_line in line_list:
                        self.ax.axvline(ref_line, color='r', alpha=1)
            else:
                for ref_line in self.line_list:
                    self.ax.axvline(ref_line, color='r', alpha=.4)


            self.ax.set_title(file_name)
            self.ax.plot(wavelength, intensity, color='k')
            self.ax.set_xlabel('Wavelength (Angstrom)')
            self.ax.set_ylabel('Intensity (ADU)')
            self.ax.set_xlim((wavelength[0], wavelength[-1]))

            self.fig.canvas.mpl_connect('button_press_event', self.on_click)
            plt.show()

            if self.cleaned_list != []:

                with open(pickle_file_name, 'wb') as list_file:
                    pickle.dump(self.cleaned_list,
                                list_file,
                                protocol=pickle.HIGHEST_PROTOCOL)
项目:goodman    作者:soar-telescope    | 项目源码 | 文件源码
def __init__(self, reference_dir):
        self.cleaned_list = []


        reference_data = ReferenceData(reference_dir)

        file_list = glob.glob(os.path.join(reference_dir, '*fits'))

        for lfile in file_list:
            self.fig, self.ax = plt.subplots()
            ccd = CCDData.read(lfile, unit=u.adu)
            read_wavelength = ReadWavelengthSolution(ccd.header, ccd.data)
            wavelength, intensity = read_wavelength()

            self.line_list = reference_data.get_line_list_by_name(
                ccd.header['OBJECT'])

            file_name = lfile.split('/')[-1]
            pickle_file_name = re.sub('.fits', '_list.pkl', file_name)

            manager = plt.get_current_fig_manager()
            manager.window.showMaximized()
            if os.path.isfile(pickle_file_name):
                with open(pickle_file_name, 'rb') as pickled_file:
                    line_list = pickle.load(pickled_file)
                    for ref_line in line_list:
                        self.ax.axvline(ref_line, color='r', alpha=1)
            else:
                for ref_line in self.line_list:
                    self.ax.axvline(ref_line, color='r', alpha=.4)


            self.ax.set_title(file_name)
            self.ax.plot(wavelength, intensity, color='k')
            self.ax.set_xlabel('Wavelength (Angstrom)')
            self.ax.set_ylabel('Intensity (ADU)')
            self.ax.set_xlim((wavelength[0], wavelength[-1]))

            self.fig.canvas.mpl_connect('button_press_event', self.on_click)
            plt.show()

            if self.cleaned_list != []:

                with open(pickle_file_name, 'wb') as list_file:
                    pickle.dump(self.cleaned_list,
                                list_file,
                                protocol=pickle.HIGHEST_PROTOCOL)
项目:decoding_challenge_cortana_2016_3rd    作者:kingjr    | 项目源码 | 文件源码
def _plot_raw_onkey(event, params):
    """Interpret key presses"""
    import matplotlib.pyplot as plt
    if event.key == 'escape':
        plt.close(params['fig'])
    elif event.key == 'down':
        params['ch_start'] += params['n_channels']
        _channels_changed(params, len(params['info']['ch_names']))
    elif event.key == 'up':
        params['ch_start'] -= params['n_channels']
        _channels_changed(params, len(params['info']['ch_names']))
    elif event.key == 'right':
        value = params['t_start'] + params['duration']
        _plot_raw_time(value, params)
        params['update_fun']()
        params['plot_fun']()
    elif event.key == 'left':
        value = params['t_start'] - params['duration']
        _plot_raw_time(value, params)
        params['update_fun']()
        params['plot_fun']()
    elif event.key in ['+', '=']:
        params['scale_factor'] *= 1.1
        params['plot_fun']()
    elif event.key == '-':
        params['scale_factor'] /= 1.1
        params['plot_fun']()
    elif event.key == 'pageup':
        n_channels = params['n_channels'] + 1
        _setup_browser_offsets(params, n_channels)
        _channels_changed(params, len(params['info']['ch_names']))
    elif event.key == 'pagedown':
        n_channels = params['n_channels'] - 1
        if n_channels == 0:
            return
        _setup_browser_offsets(params, n_channels)
        if len(params['lines']) > n_channels:  # remove line from view
            params['lines'][n_channels].set_xdata([])
            params['lines'][n_channels].set_ydata([])
        _channels_changed(params, len(params['info']['ch_names']))
    elif event.key == 'home':
        duration = params['duration'] - 1.0
        if duration <= 0:
            return
        params['duration'] = duration
        params['hsel_patch'].set_width(params['duration'])
        params['update_fun']()
        params['plot_fun']()
    elif event.key == 'end':
        duration = params['duration'] + 1.0
        if duration > params['raw'].times[-1]:
            duration = params['raw'].times[-1]
        params['duration'] = duration
        params['hsel_patch'].set_width(params['duration'])
        params['update_fun']()
        params['plot_fun']()
    elif event.key == '?':
        _onclick_help(event, params)
    elif event.key == 'f11':
        mng = plt.get_current_fig_manager()
        mng.full_screen_toggle()
项目:baxter_throw    作者:rikkimelissa    | 项目源码 | 文件源码
def replace_segment(self):
        # print "Segment ", str(self._iter), " smoothed"
        old_dur = self._vertex2[0] - self._vertex1[0]
        new_dur = self._s[-1,0] - self._s[0,0]
        if new_dur < old_dur:
            if (self._plot_demo):
                if (self._plotIndex == -1):
                    # plt.close('all')
                    self._plotIndex = 0
                    # plt.figure()
                    f, self._axarr = plt.subplots(2,2)
                    self._axarr[0,0].plot(self._traj[:,0],self._traj[:,1:8])
                    self._axarr[0,0].set_title('Iterations = 0')
            # print "replacing segment"
            self._traj = np.delete(self._traj,range(int(self._ind1),int(self._ind2+1)),0)
            self._traj[self._ind1:,0] += new_dur - old_dur
            self._traj = np.insert(self._traj,self._ind1,self._s,0)
            if (self._plot_demo):
                if self._plotIndex == 0:
                    self._axarr[0,1].plot(self._traj[:,0],self._traj[:,1:8])
                    title = "Iterations = " + str(self._plotIndex+1)
                    self._axarr[0,1].set_title(title)
                    self._plotIndex = 1
                    # plt.show(block=False)
                    # raw_input('Press enter to continue...')
                elif self._plotIndex == 1:
                    print('check 1')
                    self._axarr[1,0].plot(self._traj[:,0],self._traj[:,1:8])
                    title = "Iterations = " + str(self._plotIndex+1)
                    self._axarr[1,0].set_title(title)
                    self._plotIndex = 2
                    print ('check 2')
                     # plt.show(block=False)
                elif self._plotIndex == 2:
                    print ('check 3')
                    self._axarr[1,1].plot(self._traj[:,0],self._traj[:,1:8])
                    title = "Iterations = " + str(self._plotIndex+1)
                    self._axarr[1,1].set_title(title)
                    self._plotIndex = 3
                    plt.show(block=False)
                    wm = plt.get_current_fig_manager()
                    wm.window.wm_geometry("800x500+1000+0")
                    raw_input('Press enter to continue...')
        else:
            self._iter -=1
        if self._iter < 30:
            print "smoothing next segment"
            self._iter += 1
            self.smooth_path()
        else:
            print "sent to publish"
            self.publish_traj()
            self._executing = False
项目:baxter_throw    作者:rikkimelissa    | 项目源码 | 文件源码
def replace_segment(self):
        # print "Segment ", str(self._iter), " smoothed"
        old_dur = self._vertex2[0] - self._vertex1[0]
        new_dur = self._s[-1,0] - self._s[0,0]
        if new_dur < old_dur:
            if (self._plot_demo):
                if (self._plotIndex == -1):
                    # plt.close('all')
                    self._plotIndex = 0
                    f, self._axarr = plt.subplots(2,2)
                    self._axarr[0,0].plot(self._traj[:,0],self._traj[:,1:8])
                    self._axarr[0,0].set_title('Iterations = 0')
            # print "replacing segment"
            self._traj = np.delete(self._traj,range(int(self._ind1),int(self._ind2+1)),0)
            self._traj[self._ind1:,0] += new_dur - old_dur
            self._traj = np.insert(self._traj,self._ind1,self._s,0)
            if (self._plot_demo):
                if self._plotIndex == 0:
                    self._axarr[0,1].plot(self._traj[:,0],self._traj[:,1:8])
                    title = "Iterations = " + str(self._plotIndex+1)
                    self._axarr[0,1].set_title(title)
                    self._plotIndex = 1
                    # plt.show(block=False)
                    # raw_input('Press enter to continue...')
                elif self._plotIndex == 1:
                    print('check 1')
                    self._axarr[1,0].plot(self._traj[:,0],self._traj[:,1:8])
                    title = "Iterations = " + str(self._plotIndex+1)
                    self._axarr[1,0].set_title(title)
                    self._plotIndex = 2
                    print ('check 2')
                     # plt.show(block=False)
                elif self._plotIndex == 2:
                    print ('check 3')
                    self._axarr[1,1].plot(self._traj[:,0],self._traj[:,1:8])
                    title = "Iterations = " + str(self._plotIndex+1)
                    self._axarr[1,1].set_title(title)
                    self._plotIndex = 3
                    plt.show(block=False)
                    wm = plt.get_current_fig_manager()
                    wm.window.wm_geometry("800x500+1000+0")
                    raw_input('Press enter to continue...')
        else:
            self._iter -=1
        if self._iter < 30:
            print "smoothing next segment"
            self._iter += 1
            self.smooth_path()
        else:
            print "sent to publish"
            self.publish_traj()
            self._executing = False