(self, **kwargs)
Plots the 2D curve and the control points polygon.
Plots the 2D curve and the control points polygon.
Plots the 2D curve and the control points polygon .
def render(self, **kwargs):
        """ Plots the 2D curve and the control points polygon. """
        # Calling parent function
        super(VisCurve2D, self).render(**kwargs)

        # Initialize variables
        legend_proxy = []
        legend_names = []

        # Draw control points polygon and the curve
        fig = plt.figure(figsize=self.vconf.figure_size, dpi=self.vconf.figure_dpi)
        ax = fig.gca()

        # Start plotting
        for plot in self._plots:
            pts = np.array(plot['ptsarr'], dtype=self.vconf.dtype)
            # Plot control points
            if plot['type'] == 'ctrlpts' and self.vconf.display_ctrlpts:
                cpplot, = plt.plot(pts[:, 0], pts[:, 1], color=plot['color'], linestyle='-.', marker='o')
                legend_proxy.append(cpplot)
                legend_names.append(plot['name'])

            # Plot evaluated points
            if plot['type'] == 'evalpts' and self.vconf.display_evalpts:
                curveplt, = plt.plot(pts[:, 0], pts[:, 1], color=plot['color'], linestyle='-', alpha=self.vconf.alpha)
                legend_proxy.append(curveplt)
                legend_names.append(plot['name'])
                # Debugging for curve directions
                if self.vconf.debug_mode:
                    plt.quiver(pts[0, 0], pts[0, 1], pts[-1, 0] - pts[0, 0], pts[-1, 1] - pts[0, 1],
                               color='k', angles='xy', scale_units='xy', scale=1, width=0.003)

            # Plot bounding box
            if plot['type'] == 'bbox' and self.vconf.display_bbox:
                bboxplt, = plt.plot(pts[:, 0], pts[:, 1], color=plot['color'], linestyle='--')
                legend_proxy.append(bboxplt)
                legend_names.append(plot['name'])

            # Plot extras
            if plot['type'] == 'extras':
                extrasplt, = plt.plot(pts[:, 0], pts[:, 1],
                                      color=plot['color'][0], linestyle='-', linewidth=plot['color'][1])
                legend_proxy.append(extrasplt)
                legend_names.append(plot['name'])

        # Add legend
        if self.vconf.display_legend:
            plt.legend(legend_proxy, legend_names)

        # Remove axes
        if not self.vconf.display_axes:
            plt.axis('off')

        # Set aspect ratio
        if self.vconf.axes_equal:
            ax.set_aspect('equal')

        # Axis labels
        if self.vconf.display_labels:
            ax.set_xlabel('x')
            ax.set_ylabel('y')

        # Process keyword arguments
        fig_filename = kwargs.get('fig_save_as', None)
        fig_display = kwargs.get('display_plot', True)

        # Check if running inside a Jupyter notebook
        if not self.vconf.is_notebook():
            # Display the plot or save the figure
            if fig_display:
                plt.show()
            else:
                fig_filename = self.vconf.figure_image_filename if fig_filename is None else fig_filename
                self.vconf.save_figure_as(fig, fig_filename)
def render ( self , * * kwargs ) : # Calling parent function super ( VisCurve2D , self ) . render ( * * kwargs ) # Initialize variables legend_proxy = [ ] legend_names = [ ] # Draw control points polygon and the curve fig = plt . figure ( figsize = self . vconf . figure_size , dpi = self . vconf . figure_dpi ) ax = fig . gca ( ) # Start plotting for plot in self . _plots : pts = np . array ( plot [ 'ptsarr' ] , dtype = self . vconf . dtype ) # Plot control points if plot [ 'type' ] == 'ctrlpts' and self . vconf . display_ctrlpts : cpplot , = plt . plot ( pts [ : , 0 ] , pts [ : , 1 ] , color = plot [ 'color' ] , linestyle = '-.' , marker = 'o' ) legend_proxy . append ( cpplot ) legend_names . append ( plot [ 'name' ] ) # Plot evaluated points if plot [ 'type' ] == 'evalpts' and self . vconf . display_evalpts : curveplt , = plt . plot ( pts [ : , 0 ] , pts [ : , 1 ] , color = plot [ 'color' ] , linestyle = '-' , alpha = self . vconf . alpha ) legend_proxy . append ( curveplt ) legend_names . append ( plot [ 'name' ] ) # Debugging for curve directions if self . vconf . debug_mode : plt . quiver ( pts [ 0 , 0 ] , pts [ 0 , 1 ] , pts [ - 1 , 0 ] - pts [ 0 , 0 ] , pts [ - 1 , 1 ] - pts [ 0 , 1 ] , color = 'k' , angles = 'xy' , scale_units = 'xy' , scale = 1 , width = 0.003 ) # Plot bounding box if plot [ 'type' ] == 'bbox' and self . vconf . display_bbox : bboxplt , = plt . plot ( pts [ : , 0 ] , pts [ : , 1 ] , color = plot [ 'color' ] , linestyle = '--' ) legend_proxy . append ( bboxplt ) legend_names . append ( plot [ 'name' ] ) # Plot extras if plot [ 'type' ] == 'extras' : extrasplt , = plt . plot ( pts [ : , 0 ] , pts [ : , 1 ] , color = plot [ 'color' ] [ 0 ] , linestyle = '-' , linewidth = plot [ 'color' ] [ 1 ] ) legend_proxy . append ( extrasplt ) legend_names . append ( plot [ 'name' ] ) # Add legend if self . vconf . display_legend : plt . legend ( legend_proxy , legend_names ) # Remove axes if not self . vconf . display_axes : plt . axis ( 'off' ) # Set aspect ratio if self . vconf . axes_equal : ax . set_aspect ( 'equal' ) # Axis labels if self . vconf . display_labels : ax . set_xlabel ( 'x' ) ax . set_ylabel ( 'y' ) # Process keyword arguments fig_filename = kwargs . get ( 'fig_save_as' , None ) fig_display = kwargs . get ( 'display_plot' , True ) # Check if running inside a Jupyter notebook if not self . vconf . is_notebook ( ) : # Display the plot or save the figure if fig_display : plt . show ( ) else : fig_filename = self . vconf . figure_image_filename if fig_filename is None else fig_filename self . vconf . save_figure_as ( fig , fig_filename )