示例#1
0
 def plotAll(self,
             savefig=True,
             outfileSuffix=None,
             figformat='pdf',
             dpi=600,
             thumbnail=True,
             closefigs=True):
     """
     Make a few generically desired plots. This needs more flexibility in the future.
     """
     plotHandler = PlotHandler(outDir=self.outDir,
                               resultsDb=self.resultsDb,
                               savefig=savefig,
                               figformat=figformat,
                               dpi=dpi,
                               thumbnail=thumbnail)
     for b in self.bundleDict.values():
         try:
             b.plot(plotHandler=plotHandler,
                    outfileSuffix=outfileSuffix,
                    savefig=savefig)
         except ValueError as ve:
             message = 'Plotting failed for metricBundle %s.' % (b.fileRoot)
             message += ' Error message: %s' % (ve.message)
             warnings.warn(message)
         if closefigs:
             plt.close('all')
     if self.verbose:
         print('Plotting all metrics.')
示例#2
0
 def plotCurrent(self,
                 savefig=True,
                 outfileSuffix=None,
                 figformat='pdf',
                 dpi=600,
                 thumbnail=True,
                 closefigs=True):
     plotHandler = PlotHandler(outDir=self.outDir,
                               resultsDb=self.resultsDb,
                               savefig=savefig,
                               figformat=figformat,
                               dpi=dpi,
                               thumbnail=thumbnail)
     for b in self.currentBundleDict.itervalues():
         b.plot(plotHandler=plotHandler,
                outfileSuffix=outfileSuffix,
                savefig=savefig)
         for cb in b.childBundles.itervalues():
             cb.plot(plotHandler=plotHandler,
                     outfileSuffix=outfileSuffix,
                     savefig=savefig)
         if closefigs:
             plt.close('all')
     if self.verbose:
         print 'Plotting complete.'
示例#3
0
    def plotCurrent(self, savefig=True, outfileSuffix=None, figformat='pdf', dpi=600, thumbnail=True,
                    closefigs=True):
        """Generate the plots for the currently active set of MetricBundles.

        Parameters
        ----------
        savefig : Optional[bool]
            If True, save figures to disk, to self.outDir directory.
        outfileSuffix : Optional[str]
            Append outfileSuffix to the end of every plot file generated. Useful for generating
            sequential series of images for movies.
        figformat : Optional[str]
            Matplotlib figure format to use to save to disk. Default pdf.
        dpi : Optional[str]
            DPI for matplotlib figure. Default 600.
        thumbnail : Optional[bool]
            If True, save a small thumbnail jpg version of the output file to disk as well.
            This is useful for showMaf web pages. Default True.
        closefigs : Optional[bool]
            Close the matplotlib figures after they are saved to disk. If many figures are
            generated, closing the figures saves significant memory. Default True.
        """
        plotHandler = PlotHandler(outDir=self.outDir, resultsDb=self.resultsDb,
                                  savefig=savefig, figformat=figformat, dpi=dpi, thumbnail=thumbnail)
        for b in self.currentBundleDict.itervalues():
            b.plot(plotHandler=plotHandler, outfileSuffix=outfileSuffix, savefig=savefig)
            if closefigs:
                plt.close('all')
        if self.verbose:
            print 'Plotting complete.'
示例#4
0
    def plotCurrent(self,
                    savefig=True,
                    outfileSuffix=None,
                    figformat='pdf',
                    dpi=600,
                    trimWhitespace=True,
                    thumbnail=True,
                    closefigs=True):
        """Generate the plots for the currently active set of MetricBundles.

        Parameters
        ----------
        savefig : bool, opt
            If True, save figures to disk, to self.outDir directory.
        outfileSuffix : str, opt
            Append outfileSuffix to the end of every plot file generated. Useful for generating
            sequential series of images for movies.
        figformat : str, opt
            Matplotlib figure format to use to save to disk. Default pdf.
        dpi : int, opt
            DPI for matplotlib figure. Default 600.
        trimWhitespace : bool, opt
            If True, trim additional whitespace from final figures. Default True.
        thumbnail : bool, opt
            If True, save a small thumbnail jpg version of the output file to disk as well.
            This is useful for showMaf web pages. Default True.
        closefigs : bool, opt
            Close the matplotlib figures after they are saved to disk. If many figures are
            generated, closing the figures saves significant memory. Default True.
        """
        plotHandler = PlotHandler(outDir=self.outDir,
                                  resultsDb=self.resultsDb,
                                  savefig=savefig,
                                  figformat=figformat,
                                  dpi=dpi,
                                  trimWhitespace=trimWhitespace,
                                  thumbnail=thumbnail)

        for b in self.currentBundleDict.values():
            try:
                b.plot(plotHandler=plotHandler,
                       outfileSuffix=outfileSuffix,
                       savefig=savefig)
            except ValueError as ve:
                message = 'Plotting failed for metricBundle %s.' % (b.fileRoot)
                message += ' Error message: %s' % (ve)
                warnings.warn(message)
            if closefigs:
                plt.close('all')
        if self.verbose:
            print('Plotting complete.')
示例#5
0
    def plot(self, plotHandler=None, plotFunc=None, outfileSuffix=None, savefig=False):
        """
        Create all plots available from the slicer. plotHandler holds the output directory info, etc.
        """
        # Generate a plotHandler if none was set.
        if plotHandler is None:
            plotHandler = PlotHandler(savefig=savefig)
        # Make plots.
        if plotFunc is not None:
            if isinstance(plotFunc, BasePlotter):
                plotFunc = plotFunc
            else:
                plotFunc = plotFunc()

        plotHandler.setMetricBundles([self])
        # The plotDict will be automatically accessed when the plotHandler calls the plotting method.
        madePlots = {}
        if plotFunc is not None:
            # We haven't updated plotHandler to know about these kinds of plots yet.
            # and we want to automatically set some values for the ylabel for metricVsH.
            tmpDict = {}
            if plotFunc.plotType == 'MetricVsH':
                if 'ylabel' not in self.plotDict:
                    tmpDict['ylabel'] = self.metric.name
            fignum = plotHandler.plot(plotFunc, plotDicts=tmpDict, outfileSuffix=outfileSuffix)
            madePlots[plotFunc.plotType] = fignum
        else:
            for plotFunc in self.plotFuncs:
                # We haven't updated plotHandler to know about these kinds of plots yet.
                # and we want to automatically set some values for the ylabel for metricVsH.
                tmpDict = {}
                if plotFunc.plotType == 'MetricVsH':
                    if 'ylabel' not in self.plotDict:
                        tmpDict['ylabel'] = self.metric.name
                fignum = plotHandler.plot(plotFunc, plotDicts=tmpDict, outfileSuffix=outfileSuffix)
                madePlots[plotFunc.plotType] = fignum
        return madePlots
示例#6
0
    def plot(self,
             plotHandler=None,
             plotFunc=None,
             outfileSuffix=None,
             savefig=False):
        """
        Create all plots available from the slicer. plotHandler holds the output directory info, etc.
        """
        # Generate a plotHandler if none was set.
        if plotHandler is None:
            plotHandler = PlotHandler(savefig=savefig)
        # Make plots.
        if plotFunc is not None:
            if isinstance(plotFunc, BasePlotter):
                plotFunc = plotFunc
            else:
                plotFunc = plotFunc()

        plotHandler.setMetricBundles([self])
        # The plotDict will be automatically accessed when the plotHandler calls the plotting method.
        madePlots = {}
        if plotFunc is not None:
            # We haven't updated plotHandler to know about these kinds of plots yet.
            # and we want to automatically set some values for the ylabel for metricVsH.
            tmpDict = {}
            if plotFunc.plotType == 'MetricVsH':
                if 'ylabel' not in self.plotDict:
                    tmpDict['ylabel'] = self.metric.name
            fignum = plotHandler.plot(plotFunc,
                                      plotDicts=tmpDict,
                                      outfileSuffix=outfileSuffix)
            madePlots[plotFunc.plotType] = fignum
        else:
            for plotFunc in self.plotFuncs:
                # We haven't updated plotHandler to know about these kinds of plots yet.
                # and we want to automatically set some values for the ylabel for metricVsH.
                tmpDict = {}
                if plotFunc.plotType == 'MetricVsH':
                    if 'ylabel' not in self.plotDict:
                        tmpDict['ylabel'] = self.metric.name
                fignum = plotHandler.plot(plotFunc,
                                          plotDicts=tmpDict,
                                          outfileSuffix=outfileSuffix)
                madePlots[plotFunc.plotType] = fignum
        return madePlots