def plot_throat(self, throats, fig=None):
        r"""
        Plot a throat or list of throats in 2D showing key data

        Parameters
        ----------
        throats : list or array containing throat indices tp include in figure

        fig : matplotlib figure object to place plot in
        """
        throat_list = []
        for throat in throats:
            if throat in range(self.num_throats()):
                throat_list.append(throat)
            else:
                logger.warn('Throat: ' + str(throat) + ' not part of geometry')
        if len(throat_list) > 0:
            verts = self['throat.vertices'][throat_list]
            offsets = self['throat.offset_vertices'][throat_list]
            normals = self['throat.normal'][throat_list]
            coms = self['throat.centroid'][throat_list]
            incentre = self['throat.incenter'][throat_list]
            inradius = 0.5*self['throat.indiameter'][throat_list]
            row_col = np.ceil(np.sqrt(len(throat_list)))
            for i in range(len(throat_list)):
                if fig is None:
                    fig = plt.figure()
                ax = fig.add_subplot(row_col, row_col, i+1)
                vert_2D = self._rotate_and_chop(verts[i], normals[i],
                                                [0, 0, 1])
                hull = ConvexHull(vert_2D, qhull_options='QJ Pp')
                for simplex in hull.simplices:
                    plt.plot(vert_2D[simplex, 0], vert_2D[simplex, 1], 'k-',
                             linewidth=2)
                plt.scatter(vert_2D[:, 0], vert_2D[:, 1])
                offset_2D = self._rotate_and_chop(offsets[i], normals[i],
                                                  [0, 0, 1])
                offset_hull = ConvexHull(offset_2D, qhull_options='QJ Pp')
                for simplex in offset_hull.simplices:
                    plt.plot(offset_2D[simplex, 0], offset_2D[simplex, 1],
                             'g-', linewidth=2)
                plt.scatter(offset_2D[:, 0], offset_2D[:, 1])
                # Make sure the plot looks nice by finding the greatest
                # range of points and setting the plot to look square
                xmax = vert_2D[:, 0].max()
                xmin = vert_2D[:, 0].min()
                ymax = vert_2D[:, 1].max()
                ymin = vert_2D[:, 1].min()
                x_range = xmax - xmin
                y_range = ymax - ymin
                if (x_range > y_range):
                    my_range = x_range
                else:
                    my_range = y_range
                lower_bound_x = xmin - my_range*0.5
                upper_bound_x = xmin + my_range*1.5
                lower_bound_y = ymin - my_range*0.5
                upper_bound_y = ymin + my_range*1.5
                plt.axis((lower_bound_x, upper_bound_x, lower_bound_y,
                          upper_bound_y))
                plt.grid(b=True, which='major', color='b', linestyle='-')
                centroid = self._rotate_and_chop(coms[i], normals[i],
                                                 [0, 0, 1])
                incent = self._rotate_and_chop(incentre[i], normals[i],
                                               [0, 0, 1])
                plt.scatter(centroid[0][0], centroid[0][1])
                plt.scatter(incent[0][0], incent[0][1], c='r')
                # Plot incircle
                t = np.linspace(0, 2*np.pi, 200)
                u = inradius[i]*np.cos(t)+incent[0][0]
                v = inradius[i]*np.sin(t)+incent[0][1]
                plt.plot(u, v, 'r-')
                ax.ticklabel_format(style='sci', scilimits=(0, 0))
        else:
            logger.error("Please provide throat indices")
        return fig
def plot_throat ( self , throats , fig = None ) : throat_list = [ ] for throat in throats : if throat in range ( self . num_throats ( ) ) : throat_list . append ( throat ) else : logger . warn ( 'Throat: ' + str ( throat ) + ' not part of geometry' ) if len ( throat_list ) > 0 : verts = self [ 'throat.vertices' ] [ throat_list ] offsets = self [ 'throat.offset_vertices' ] [ throat_list ] normals = self [ 'throat.normal' ] [ throat_list ] coms = self [ 'throat.centroid' ] [ throat_list ] incentre = self [ 'throat.incenter' ] [ throat_list ] inradius = 0.5 * self [ 'throat.indiameter' ] [ throat_list ] row_col = np . ceil ( np . sqrt ( len ( throat_list ) ) ) for i in range ( len ( throat_list ) ) : if fig is None : fig = plt . figure ( ) ax = fig . add_subplot ( row_col , row_col , i + 1 ) vert_2D = self . _rotate_and_chop ( verts [ i ] , normals [ i ] , [ 0 , 0 , 1 ] ) hull = ConvexHull ( vert_2D , qhull_options = 'QJ Pp' ) for simplex in hull . simplices : plt . plot ( vert_2D [ simplex , 0 ] , vert_2D [ simplex , 1 ] , 'k-' , linewidth = 2 ) plt . scatter ( vert_2D [ : , 0 ] , vert_2D [ : , 1 ] ) offset_2D = self . _rotate_and_chop ( offsets [ i ] , normals [ i ] , [ 0 , 0 , 1 ] ) offset_hull = ConvexHull ( offset_2D , qhull_options = 'QJ Pp' ) for simplex in offset_hull . simplices : plt . plot ( offset_2D [ simplex , 0 ] , offset_2D [ simplex , 1 ] , 'g-' , linewidth = 2 ) plt . scatter ( offset_2D [ : , 0 ] , offset_2D [ : , 1 ] ) xmax = vert_2D [ : , 0 ] . max ( ) xmin = vert_2D [ : , 0 ] . min ( ) ymax = vert_2D [ : , 1 ] . max ( ) ymin = vert_2D [ : , 1 ] . min ( ) x_range = xmax - xmin y_range = ymax - ymin if ( x_range > y_range ) : my_range = x_range else : my_range = y_range lower_bound_x = xmin - my_range * 0.5 upper_bound_x = xmin + my_range * 1.5 lower_bound_y = ymin - my_range * 0.5 upper_bound_y = ymin + my_range * 1.5 plt . axis ( ( lower_bound_x , upper_bound_x , lower_bound_y , upper_bound_y ) ) plt . grid ( b = True , which = 'major' , color = 'b' , linestyle = '-' ) centroid = self . _rotate_and_chop ( coms [ i ] , normals [ i ] , [ 0 , 0 , 1 ] ) incent = self . _rotate_and_chop ( incentre [ i ] , normals [ i ] , [ 0 , 0 , 1 ] ) plt . scatter ( centroid [ 0 ] [ 0 ] , centroid [ 0 ] [ 1 ] ) plt . scatter ( incent [ 0 ] [ 0 ] , incent [ 0 ] [ 1 ] , c = 'r' ) t = np . linspace ( 0 , 2 * np . pi , 200 ) u = inradius [ i ] * np . cos ( t ) + incent [ 0 ] [ 0 ] v = inradius [ i ] * np . sin ( t ) + incent [ 0 ] [ 1 ] plt . plot ( u , v , 'r-' ) ax . ticklabel_format ( style = 'sci' , scilimits = ( 0 , 0 ) ) else : logger . error ( "Please provide throat indices" ) return fig
r"""
        Plot a throat or list of throats in 2D showing key data

        Parameters
        ----------
        throats : list or array containing throat indices tp include in figure

        fig : matplotlib figure object to place plot in