__init__.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:SimpSOM 作者: fcomitani 项目源码 文件源码
def nodes_graph(self, colnum=0, show=False, printout=True):

        """Plot a 2D map with hexagonal nodes and weights values

        Args:
            colnum (int): The index of the weight that will be shown as colormap.
            show (bool, optional): Choose to display the plot.
            printout (bool, optional): Choose to save the plot to a file.

        """

        centers = [[node.pos[0],node.pos[1]] for node in self.nodeList]

        widthP=100
        dpi=72
        xInch = self.netWidth*widthP/dpi 
        yInch = self.netHeight*widthP/dpi 
        fig=plt.figure(figsize=(xInch, yInch), dpi=dpi)

        if self.colorEx==True:
            cols = [[np.float(node.weights[0]),np.float(node.weights[1]),np.float(node.weights[2])]for node in self.nodeList]   
            ax = hx.plot_hex(fig, centers, cols)
            ax.set_title('Node Grid w Color Features', size=80)
            printName='nodesColors.png'

        else:
            cols = [node.weights[colnum] for node in self.nodeList]
            ax = hx.plot_hex(fig, centers, cols)
            ax.set_title('Node Grid w Feature #' +  str(colnum), size=80)
            divider = make_axes_locatable(ax)
            cax = divider.append_axes("right", size="5%", pad=0.0)
            cbar=plt.colorbar(ax.collections[0], cax=cax)
            cbar.set_label('Feature #' +  str(colnum)+' value', size=80, labelpad=50)
            cbar.ax.tick_params(labelsize=60)
            plt.sca(ax)
            printName='nodesFeature_'+str(colnum)+'.png'

        if printout==True:
            plt.savefig(printName, bbox_inches='tight', dpi=dpi)
        if show==True:
            plt.show()
        if show!=False and printout!=False:
            plt.clf()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号