Ejemplo n.º 1
0
    def run(self):
        from xmipp import MetaData, str2Label
        from protlib_gui_figure import XmippPlotter

        md = MetaData(self.getParam('-i'))
        if self.checkParam('--xlabel'):
            xlabel = self.getParam('--xlabel')
            mdLabelX = str2Label(xlabel)
        else:
            xlabel = ""
            mdLabelX = None

        if self.checkParam('--xtitle'):
            xlabel = self.getParam('--xtitle')
        ylabels = self.getParam('--ylabel').split()
        if self.checkParam('--ytitle'):
            ylabel = self.getParam('--ytitle')
        else:
            ylabel = ylabels[0]

        colors, lenColors = self.getList('--colors',
                                         ['g', 'b', 'r', 'y', 'c', 'm', 'k'])
        markers, lenMarkers = self.getList('--markers')
        styles, lenStyles = self.getList('--style')

        if self.checkParam('--nbins'):
            nBins = self.getIntParam('--nbins')
        else:
            nBins = None

        title = self.getParam('--title')
        xplotter = XmippPlotter()
        xplotter.createSubPlot(title, xlabel, ylabel)

        for i, l in enumerate(ylabels):
            c = colors[i % lenColors]
            m = markers[i % lenMarkers]
            if m == "none":
                m = None
            s = styles[i % lenStyles]
            if s == "none":
                s = None
            xplotter.plotMd(md,
                            mdLabelX,
                            str2Label(l),
                            color=c,
                            marker=m,
                            linestyle=s,
                            nbins=nBins)  # if nbins is present do an histogram

        legendLocation = self.getParam('--legend')
        if legendLocation != 'none':
            xplotter.showLegend(ylabels, loc=legendLocation.replace('_', ' '))
        xplotter.show()