Exemplo n.º 1
0
    def plotMeta(self):
        fig, ax = plt.subplots(2,
                               1,
                               figsize=(self.config.getPrintToFileWidth(),
                                        self.config.getPrintToFileHeight()))
        self.event = Event(self.config, self.fig, self.data.getTitle(),
                           self.plotType, self.debug)
        # For saving the pic we use a generic event object
        fig.canvas.mpl_connect('key_press_event', self.event.onEvent)
        plt.subplots_adjust(wspace=0, hspace=0)

        valueSet = self.data.getMetaDataValues().keys()
        results = self.data.getResults()
        metaColors = self.config.getMetaColors()
        self.colors = assignColors2MetaDataValue(self.data.getMetaDataValues(),
                                                 metaColors)
        allTargetScores = self.data.getTargetScores()
        allNonTargetScores = self.data.getNonTargetScores()
        self._plot(ax, allTargetScores, allNonTargetScores)

        fig.tight_layout()
        if self.config.getPrintToFile():
            filename = "%s_%s_%s.%s" % (self.printToFilename, self.plotType,
                                        self.plotType, "png")
            print("Writing plot to %s" % filename)
            plt.savefig(filename, orientation='landscape', papertype='letter')
        else:
            plt.show()
Exemplo n.º 2
0
    def __init__(self, thisData, thisCllrWrapper, thisConfig, thisExpName, thisDebug=True):
        self.data = thisData
        self.cllr = thisCllrWrapper
        self.config = thisConfig
        self._printToFilename = thisExpName
        self._expName = thisExpName
        self.debug = thisDebug
        Probability.__init__(self, self.data, self.config, self.debug)
        self.plotType = 'eer_plot'
        self.fig = None
        self.event = None

        metaDataValues = self.data.getMetaDataValues()
        metaColors = self.config.getMetaColors()
        self.colors = assignColors2MetaDataValue(metaDataValues, metaColors)

        self.eerData = self.computeProbabilities(self.eerFunc)
        self.eerValue = {}
        self.score = {}
        for thisMetaValue in sorted(self.colors.keys()):
            for metaValue, PD, PP, X in self.eerData:
                if thisMetaValue == metaValue:
                    try:
                        self.eerValue[metaValue], self.score[metaValue] = self.computeEer(PD, PP, X)
                        print("EER: {:.4f} % at score: {:.4f} and meta value: {}".format(
                            self.eerValue[metaValue] * 100, self.score[metaValue], metaValue)
                        )
                    except Exception as e:
                        print("Problem computing EER for %s: %s" % (thisMetaValue, e))
                    else:
                        self.eerValue[metaValue] *= 100
                    break
Exemplo n.º 3
0
    def plot(self):
        self.fig = plt.figure(figsize=(self.config.getPrintToFileWidth(), self.config.getPrintToFileHeight()))
        self.event = Event(self.config, self.fig, self.data.getTitle(), self.plotType, self.debug)
        # For saving the pic we use a generic event object
        self.fig.canvas.mpl_connect('key_press_event', self.event.onEvent)
        axes = self.fig.add_subplot(111)
        metaDataValues = self.data.getMetaDataValues()
        metaColors = self.config.getMetaColors()
        colors = assignColors2MetaDataValue(metaDataValues, metaColors)

        lt = LegendText(self.data, self._cllrObject, colors, self.config, self.config.getShowCllrInDet(),
                        self.config.getShowMinCllrInDet(), self.config.getShowEerInDet(),
                        self.config.getShowCountsInDet(),
                        self._eerObject.eerValue, self.debug)

        legendText = lt.make()

        eerData = self.computeProbabilities(self.tippetFunc)

        for (metaValue, PD, PP, X) in eerData:
            pFr, = axes.plot(X, PP, 's-', label="P(pros): %s" % lt.half(legendText[metaValue])[0], color=colors[metaValue])
            pFa, = axes.plot(X, PD, 'o-', label="P(def): %s" % lt.half(legendText[metaValue])[1], color=colors[metaValue])

        plt.legend()
        axes.set_title("Tippett Plot: P(defense) and P(prosecution) for '%s'" % self.data.getTitle())
        plt.xlabel('score')
        plt.ylabel('Probability (cumulative distribution function)')
        plt.grid()
        if self.config.getPrintToFile():
            filename = "%s_%s.%s" % (self._printToFilename, self.plotType, "png")
            print("Writing plot to %s" % filename)
            plt.savefig(filename, orientation='landscape', papertype='letter')
        else:
            plt.show()
Exemplo n.º 4
0
 def plot(self):
     """
     Cumulative Ranking Plot
     """
     self.fig = plt.figure(figsize=(self.config.getPrintToFileWidth(),
                                    self.config.getPrintToFileHeight()))
     self.plotType = "ranking_plot"
     self.event = Event(self.config, self.fig, self.title, self.plotType,
                        self.debug)
     self.fig.canvas.mpl_connect('key_press_event', self.event.onEvent)
     axes = self.fig.add_subplot(111)
     metaColors = self.config.getMetaColors()
     metaDataValues = self.data.getMetaDataValues()
     self.colors = assignColors2MetaDataValue(metaDataValues, metaColors)
     self.nrColors = len(self.colors.keys())
     xlab = "Rank "
     for metaValue in metaDataValues:
         ranking, maxRank = self.computeRanking(metaValue)
         nr = len(ranking)
         x = []
         y = []
         increment = 1
         # range of the scores in 100 steps
         for thisRank in range(1, maxRank, increment):
             y.append(
                 float(self.getNrLabels(ranking, thisRank)) / float(nr) *
                 100.0)
             x.append(thisRank)
         axes.plot(x,
                   y,
                   "o-",
                   color=self.colors[metaValue],
                   label=metaValue)
         # prepare x-label.
         axes.set_xlim(0, maxRank * 1.05)
         axes.set_ylim(0, 100)
         axes.set_title("Ranking plot for '%s'" % self.title)
         xlab += metaValue + ": " + self._mkPercentString(y) + "\n"
         #print(metaValue)
     # Add labels to the plot.
     plt.ylabel('Probability')
     # Show the x-label without the last /n.
     plt.xlabel(xlab[:-1])
     # Add a legend to the plot.
     axes.legend(loc=5)
     # Add a grid to the plot.
     plt.grid()
     # If so desired, print the plot to a file.
     if self.config.getPrintToFile():
         filename = "%s_%s.%s" % (self._printToFilename, self.plotType,
                                  "png")
         print("Writing plot to %s" % filename)
         plt.savefig(filename, orientation='landscape', papertype='letter')
     else:
         # Finally: show the plot.
         plt.show()
Exemplo n.º 5
0
    def plot(self):
        self.fig = plt.figure(figsize=(self.config.getPrintToFileWidth(),
                                       self.config.getPrintToFileHeight()))
        self.event = Event(self.config, self.fig, self.data.getTitle(),
                           self.plotType, self.debug)
        # For saving the pic we use a generic event object
        self.fig.canvas.mpl_connect('key_press_event', self.event.onEvent)
        axes = self.fig.add_subplot(111)
        metaDataValues = self.data.getMetaDataValues()
        metaColors = self.config.getMetaColors()
        colors = assignColors2MetaDataValue(metaDataValues, metaColors)

        lt = LegendText(self.data, self._cllrObject, colors, self.config,
                        self.config.getShowCllrInDet(),
                        self.config.getShowMinCllrInDet(),
                        self.config.getShowEerInDet(),
                        self.config.getShowCountsInDet(),
                        self._eerObject.eerValue, self._eerObject.eerScore,
                        self.debug)

        legendText = lt.make()

        eerData = self.computeProbabilities(self.tippetFunc)

        for (metaValue, PD, PP, X) in eerData:
            pFr, = axes.plot(X,
                             PP,
                             's-',
                             label="P(pros): %s" %
                             lt.half(legendText[metaValue])[0],
                             color=colors[metaValue])
            pFa, = axes.plot(X,
                             PD,
                             'o-',
                             label="P(def): %s" %
                             lt.half(legendText[metaValue])[1],
                             color=colors[metaValue])

        plt.legend()
        axes.set_title("Tippett Plot: P(defense) and P(prosecution) for '%s'" %
                       self.data.getTitle())
        plt.xlabel('score')
        plt.ylabel('Probability (cumulative distribution function)')
        plt.grid()
        if self.config.getPrintToFile():
            filename = "%s_%s.%s" % (self._printToFilename, self.plotType,
                                     "png")
            print("Writing plot to %s" % filename)
            plt.savefig(filename, orientation='landscape', papertype='letter')
        else:
            plt.show()
Exemplo n.º 6
0
    def plot(self):
        self.fig = plt.figure(figsize=(self.config.getPrintToFileWidth(),
                                       self.config.getPrintToFileHeight()))
        self.event = Event(self.config, self.fig, self.data.getTitle(),
                           self.plotType, self.debug)
        # For saving the pic we use a generic event object
        self.fig.canvas.mpl_connect('key_press_event', self.event.onEvent)
        axes = self.fig.add_subplot(111)
        metaDataValues = self.data.getMetaDataValues()
        metaColors = self.config.getMetaColors()
        colors = assignColors2MetaDataValue(metaDataValues, metaColors)

        lt = LegendText(self.data, self._cllrObject, colors, self.config,
                        self.config.getShowCllrInDet(),
                        self.config.getShowMinCllrInDet(),
                        self.config.getShowEerInDet(),
                        self.config.getShowCountsInDet(),
                        self._eerObject.eerValue, self._eerObject.eerScore,
                        self.debug)
        legendText = lt.make()

        for metaValue in metaDataValues:
            targetScores = self.data.getTargetScores4MetaValue(metaValue)
            nonTargetScores = self.data.getNonTargetScores4MetaValue(metaValue)
            allScores = targetScores + nonTargetScores
            truthValues = np.ones(len(allScores))
            truthValues[0:len(targetScores)] = 1
            truthValues[len(targetScores):] = 0
            fpr, tpr, thresholds = metrics.roc_curve(truthValues,
                                                     allScores,
                                                     pos_label=1)
            bla, = axes.plot(fpr,
                             tpr,
                             'x-',
                             label=legendText[metaValue],
                             color=colors[metaValue])
        #axes.set_title("Receiver Operating Characteristic for '%s'" % self.data.getTitle())
        axes.set_title("ROC plot for '%s'" % self.data.getTitle())
        plt.xlabel('P(false positive)')
        plt.ylabel('P(true positive)')
        plt.grid()
        plt.legend(loc=5)  # Position legend at center right.
        if self.config.getPrintToFile():
            filename = "%s_%s.%s" % (self._printToFilename, self.plotType,
                                     "png")
            print("Writing plot to %s" % filename)
            plt.savefig(filename, orientation='landscape', papertype='letter')
        else:
            plt.show()
Exemplo n.º 7
0
 def plot(self):
     """
     Cumulative Ranking Plot
     """
     self.fig = plt.figure(figsize=(self.config.getPrintToFileWidth(), self.config.getPrintToFileHeight()))
     self.plotType = "ranking_plot"
     self.event = Event(self.config, self.fig, self.title, self.plotType, self.debug)
     self.fig.canvas.mpl_connect('key_press_event', self.event.onEvent)
     axes = self.fig.add_subplot(111)
     metaColors = self.config.getMetaColors()
     metaDataValues = self.data.getMetaDataValues()
     self.colors = assignColors2MetaDataValue(metaDataValues, metaColors)
     self.nrColors = len(self.colors.keys())
     xlab = "Rank "
     for metaValue in metaDataValues:
         ranking, maxRank = self.computeRanking(metaValue)
         nr = len(ranking)
         x = []
         y = []
         increment = 1
         # range of the scores in 100 steps
         for thisRank in range(1, maxRank, increment):
             y.append(float(self.getNrLabels(ranking, thisRank)) / float(nr) * 100.0)
             x.append(thisRank)
         axes.plot(x, y, "o-", color=self.colors[metaValue], label=metaValue)
         # prepare x-label.
         axes.set_xlim(0, maxRank * 1.05)
         axes.set_ylim(0, 100)
         axes.set_title("Ranking plot for '%s'" % self.title)
         xlab += metaValue + ": " + self._mkPercentString(y) + "\n"
         #print(metaValue)
     # Add labels to the plot.
     plt.ylabel('Probability')
     # Show the x-label without the last /n.
     plt.xlabel(xlab[:-1])
     # Add a legend to the plot.
     axes.legend(loc=5)
     # Add a grid to the plot.
     plt.grid()
     # If so desired, print the plot to a file.
     if self.config.getPrintToFile():
         filename = "%s_%s.%s" % (self._printToFilename, self.plotType, "png")
         print("Writing plot to %s" % filename)
         plt.savefig(filename, orientation='landscape', papertype='letter')
     else:
         # Finally: show the plot.
         plt.show()
Exemplo n.º 8
0
    def __init__(self,
                 thisData,
                 thisCllrWrapper,
                 thisConfig,
                 thisExpName,
                 thisDebug=True):
        self.data = thisData
        self.cllr = thisCllrWrapper
        self.config = thisConfig
        self._printToFilename = thisExpName
        self._expName = thisExpName
        self.debug = thisDebug
        Probability.__init__(self, self.data, self.config, self.debug)
        self.plotType = 'eer_plot'
        self.fig = None
        self.event = None

        metaDataValues = self.data.getMetaDataValues()
        metaColors = self.config.getMetaColors()
        self.colors = assignColors2MetaDataValue(metaDataValues, metaColors)

        self.eerData = self.computeProbabilities(self.eerFunc)
        self.eerValue = {}
        self.eerScore = {}
        for thisMetaValue in sorted(self.colors.keys()):
            for metaValue, PD, PP, X in self.eerData:
                if thisMetaValue == metaValue:
                    try:
                        self.eerValue[metaValue], self.eerScore[
                            metaValue] = self.computeEer(PD, PP, X)
                        print(
                            "EER: {:.4f} % at score: {:.4f} and meta value: {}"
                            .format(self.eerValue[metaValue] * 100,
                                    self.eerScore[metaValue], metaValue))
                    except Exception as e:
                        print("Problem computing EER for %s: %s" %
                              (thisMetaValue, e))
                    else:
                        self.eerValue[metaValue] *= 100
                    break
Exemplo n.º 9
0
    def plot(self):
        self.fig = plt.figure(figsize=(self.config.getPrintToFileWidth(), self.config.getPrintToFileHeight()))
        self.event = Event(self.config, self.fig, self.data.getTitle(), self.plotType, self.debug)
        # For saving the pic we use a generic event object
        self.fig.canvas.mpl_connect('key_press_event', self.event.onEvent)
        axes = self.fig.add_subplot(111)
        metaDataValues = self.data.getMetaDataValues()
        metaColors = self.config.getMetaColors()
        colors = assignColors2MetaDataValue(metaDataValues, metaColors)

        lt = LegendText(self.data, self._cllrObject, colors, self.config, self.config.getShowCllrInDet(),
                        self.config.getShowMinCllrInDet(), self.config.getShowEerInDet(),
                        self.config.getShowCountsInDet(),
                        self._eerObject.eerValue, self.debug)
        legendText = lt.make()

        for metaValue in metaDataValues:
            targetScores = self.data.getTargetScores4MetaValue(metaValue)
            nonTargetScores = self.data.getNonTargetScores4MetaValue(metaValue)
            allScores = targetScores + nonTargetScores
            truthValues = np.ones(len(allScores))
            truthValues[0:len(targetScores)] = 1
            truthValues[len(targetScores):] = 0
            fpr, tpr, thresholds = metrics.roc_curve(truthValues, allScores, pos_label=1)
            bla, = axes.plot(fpr, tpr, 'x-', label=legendText[metaValue], color=colors[metaValue])
        #axes.set_title("Receiver Operating Characteristic for '%s'" % self.data.getTitle())
        axes.set_title("ROC plot for '%s'" % self.data.getTitle())
        plt.xlabel('P(false positive)')
        plt.ylabel('P(true positive)')
        plt.grid()
        plt.legend(loc=5)  # Position legend at center right.
        if self.config.getPrintToFile():
            filename = "%s_%s.%s" % (self._printToFilename, self.plotType, "png")
            print("Writing plot to %s" % filename)
            plt.savefig(filename, orientation='landscape', papertype='letter')
        else:
            plt.show()
Exemplo n.º 10
0
    def plotHistogramWithMeta(self):
        self.plotType = "histogram_plot"
        targetScores = self.data.getTargetScoreValues()
        nonTargetScores = self.data.getNonTargetScoreValues()
        self.fig = plt.figure(figsize=(self.config.getPrintToFileWidth(),
                                       self.config.getPrintToFileHeight()))
        self.event = Event(self.config, self.fig, self.title, self.plotType,
                           self.debug)
        self.fig.canvas.mpl_connect('key_press_event', self.event.onEvent)

        suggestedNrBins = max(len(targetScores), len(nonTargetScores))
        nrBins = self.config.getNrBins(suggestedNrBins)
        # Make a normed histogram. It'll be multiplied by 100 later.
        if self.type == 'cumulative':
            plt.hist(nonTargetScores,
                     bins=nrBins,
                     normed=self.config.getNormHist(),
                     facecolor='red',
                     alpha=1.0,
                     histtype='step',
                     cumulative=-1)
            plt.hist(targetScores,
                     bins=nrBins,
                     normed=self.config.getNormHist(),
                     facecolor='green',
                     alpha=0.7,
                     histtype='step',
                     cumulative=True)
            plt.title(r"Cumulative histogram for '%s'" % self.title)
        else:
            if self.config.getShowMetaInHist():
                # Split target and non target scores per meta data value
                valueSet = self.data.getMetaDataValues().keys()
                if self.debug:
                    print('valueSet:', valueSet)
                targetHistData = {}
                nonTargetHistData = {}
                metaColors = self.config.getMetaColors()
                self.colors = assignColors2MetaDataValue(
                    self.data.getMetaDataValues(), metaColors)
                self.nrColors = len(self.colors.keys())
                if self.debug:
                    print('colors:', self.colors)
                    print('nr colors:', self.nrColors)

                for value in valueSet:
                    targetHistData[value] = []
                    nonTargetHistData[value] = []
                    for label in self.data.getTargetLabels():
                        template = label + self.LABEL_SEPARATOR + value
                        targetHistData[value] += self.data.getTargetScores(
                        )[template]
                    for label in self.data.getNonTargetLabels():
                        template = label + self.LABEL_SEPARATOR + value
                        nonTargetHistData[
                            value] += self.data.getNonTargetScores()[template]
                alpha = 1.0
                allData = []
                allLabels = []
                allColors = []
                for value in targetHistData:
                    try:
                        allColors.append(self.colors[value])
                        allData.append(targetHistData[value])
                        allLabels.append(value + ' (target)')
                    except Exception:
                        pass
                for value in nonTargetHistData:
                    try:
                        allColors.append(self.colors[value])
                        allData.append(nonTargetHistData[value])
                        allLabels.append(value + ' (non target)')
                    except Exception:
                        pass
                if self.debug:
                    print('allColors:', allColors)
                try:
                    if len(self.colors) > 1:
                        # If we pair colours, this makes it difficult to distinguish between target and non target
                        # scores for one label.
                        # plt.hist(allData, bins=nrBins, normed=self.config.getNormHist(), alpha=alpha, label=allLabels, color=allColors)
                        plt.hist(allData,
                                 bins=nrBins,
                                 normed=self.config.getNormHist(),
                                 alpha=alpha,
                                 label=allLabels)
                    else:
                        plt.hist(allData,
                                 bins=nrBins,
                                 normed=self.config.getNormHist(),
                                 alpha=alpha,
                                 label=allLabels)
                except Exception:
                    print("Error: could not plot histogram!")
                    print("len(allData): %d\nnrBins: %d" %
                          (len(allData), self.config.getNrBins()))
                    print("allLabels: %s" % allLabels)
                    pass
                else:
                    plt.title("Histogram for '%s'" % self.title)
                    plt.legend()
            else:
                plt.hist(nonTargetScores,
                         bins=nrBins,
                         normed=self.config.getNormHist(),
                         facecolor='red',
                         alpha=1.0)
                plt.hist(targetScores,
                         bins=nrBins,
                         normed=self.config.getNormHist(),
                         facecolor='green',
                         alpha=0.7)
                plt.title(r"Histogram for '%s'" % self.title)
        plt.grid(True)
        plt.xlabel('Target and Non Target Scores')
        if self.config.getPrintToFile():
            filename = "%s_%s_%s.%s" % (self._printToFilename, self.plotType,
                                        self.type, "png")
            print("Writing plot to %s" % filename)
            plt.savefig(filename, orientation='landscape', papertype='letter')
        else:
            plt.show()
Exemplo n.º 11
0
    def plot(self):
        self.fig = plt.figure(figsize=(self.config.getPrintToFileWidth(), self.config.getPrintToFileHeight()))
        self.event = Event(self.config, self.fig, self._expName, self.plotType, self.debug)
        # For saving the pic we use a generic event object
        self.fig.canvas.mpl_connect('key_press_event', self.event.onEvent)
        axes = self.fig.add_subplot(111)

        metaDataValues = self.data.getMetaDataValues()
        metaColors = self.config.getMetaColors()
        colors = assignColors2MetaDataValue(metaDataValues, metaColors)

        points = 100
        title = 'DET plot'
        figure = plt.gcf()
        figure.set_figheight(figure.get_figheight() * 1.3)

        desiredTicks = ["0.00001", "0.00002", "0.00005", "0.0001", "0.0002", "0.0005", "0.001", "0.002", "0.005",
                        "0.01", "0.02", "0.05", "0.1", "0.2", "0.4", "0.6", "0.8", "0.9", "0.95", "0.98", "0.99",
                        "0.995",
                        "0.998", "0.999", "0.9995", "0.9998", "0.9999", "0.99995", "0.99998", "0.99999"]

        desiredLabels = self.config.getAllowedRates()

        # Available styles: please note that we plot up to the number of styles
        # available. So, for coloured plots, we can go up to 6 lines in a single
        # plot. For gray scaled ones, up to 12. If you need more plots just extend the
        # list bellow.

        limits = ('0.1', str(self.config.getMaxFalseRejectionRate()), '0.1', str(self.config.getMaxFalseAcceptRate()))

        # Check limits.
        for k in limits:
            if k not in desiredLabels:
                raise (SyntaxError, 'Unsupported limit %s. Please use one of %s' % (k, desiredLabels))

        lt = LegendText(self.data, self._cllrObject, colors, self.config, self.config.getShowCllrInDet(),
                        self.config.getShowMinCllrInDet(), self.config.getShowEerInDet(),
                        self.config.getShowCountsInDet(),
                        self._eerObject.eerValue, self.debug)
        legendText = lt.make()

        for metaValue in metaDataValues:
            negatives = [np.array([k for k in self.data.getNonTargetScores4MetaValue(metaValue)], dtype='float64')]
            positives = [np.array([k for k in self.data.getTargetScores4MetaValue(metaValue)], dtype='float64')]
            for neg, pos in zip(negatives, positives):
                ppfar, ppfrr = self._evalDET(neg, pos, points)
                plt.plot(ppfar, ppfrr, label=legendText[metaValue], color=colors[metaValue])

        fr_minIndex = desiredLabels.index(limits[0])
        fr_maxIndex = desiredLabels.index(limits[1])
        fa_minIndex = desiredLabels.index(limits[2])
        fa_maxIndex = desiredLabels.index(limits[3])

        # Convert into DET scale
        pticks = [self.__ppndf__(float(v)) for v in desiredTicks]

        # Plot diagonal line to facilitate reading the EER-value(s) from the plot.
        if self.config.getShowDiagonalInDet():
            plt.plot(pticks, pticks, color='red', lw=1.0, linestyle="-.")

        ax = plt.gca()

        plt.axis([pticks[fa_minIndex], pticks[fa_maxIndex], pticks[fr_minIndex], pticks[fr_maxIndex]])

        ax.set_yticks(pticks[fr_minIndex:fr_maxIndex])
        ax.set_yticklabels(desiredLabels[fr_minIndex:fr_maxIndex], size='x-small', rotation='horizontal')
        ax.set_xticks(pticks[fa_minIndex:fa_maxIndex])
        ax.set_xticklabels(desiredLabels[fa_minIndex:fa_maxIndex], size='x-small', rotation='vertical')
        if title:
            plt.title("DET plot for '" + self.data.getTitle() + "'")
            plt.grid(True)
            plt.ylabel('False Rejection Rate [%]')
            plt.xlabel('False Acceptance Rate [%]')
        plt.legend(loc=1)
        if self.config.getPrintToFile():
            filename = "%s_%s.%s" % (self._printToFilename, self.plotType, "png")
            print("Writing plot to %s" % filename)
            plt.savefig(filename, orientation='landscape', papertype='letter')
        else:
            plt.show()
Exemplo n.º 12
0
    def plot(self):
        self.fig = plt.figure(figsize=(self.config.getPrintToFileWidth(),
                                       self.config.getPrintToFileHeight()))
        self.event = Event(self.config, self.fig, self._expName, self.plotType,
                           self.debug)
        # For saving the pic we use a generic event object
        self.fig.canvas.mpl_connect('key_press_event', self.event.onEvent)
        axes = self.fig.add_subplot(111)

        metaDataValues = self.data.getMetaDataValues()
        metaColors = self.config.getMetaColors()
        colors = assignColors2MetaDataValue(metaDataValues, metaColors)

        points = 100
        title = 'DET plot'
        figure = plt.gcf()
        figure.set_figheight(figure.get_figheight() * 1.3)

        desiredTicks = [
            "0.00001", "0.00002", "0.00005", "0.0001", "0.0002", "0.0005",
            "0.001", "0.002", "0.005", "0.01", "0.02", "0.05", "0.1", "0.2",
            "0.4", "0.6", "0.8", "0.9", "0.95", "0.98", "0.99", "0.995",
            "0.998", "0.999", "0.9995", "0.9998", "0.9999", "0.99995",
            "0.99998", "0.99999"
        ]

        desiredLabels = self.config.getAllowedRates()

        # Available styles: please note that we plot up to the number of styles
        # available. So, for coloured plots, we can go up to 6 lines in a single
        # plot. For gray scaled ones, up to 12. If you need more plots just extend the
        # list bellow.

        limits = ('0.1', str(self.config.getMaxFalseRejectionRate()), '0.1',
                  str(self.config.getMaxFalseAcceptRate()))

        # Check limits.
        for k in limits:
            if k not in desiredLabels:
                raise (SyntaxError,
                       'Unsupported limit %s. Please use one of %s' %
                       (k, desiredLabels))

        lt = LegendText(self.data, self._cllrObject, colors, self.config,
                        self.config.getShowCllrInDet(),
                        self.config.getShowMinCllrInDet(),
                        self.config.getShowEerInDet(),
                        self.config.getShowCountsInDet(),
                        self._eerObject.eerValue, self._eerObject.eerScore,
                        self.debug)
        legendText = lt.make()

        for metaValue in metaDataValues:
            negatives = [
                np.array([
                    k
                    for k in self.data.getNonTargetScores4MetaValue(metaValue)
                ],
                         dtype='float64')
            ]
            positives = [
                np.array([
                    k for k in self.data.getTargetScores4MetaValue(metaValue)
                ],
                         dtype='float64')
            ]
            for neg, pos in zip(negatives, positives):
                ppfar, ppfrr = self._evalDET(neg, pos, points)
                plt.plot(ppfar,
                         ppfrr,
                         label=legendText[metaValue],
                         color=colors[metaValue])

        fr_minIndex = desiredLabels.index(limits[0])
        fr_maxIndex = desiredLabels.index(limits[1])
        fa_minIndex = desiredLabels.index(limits[2])
        fa_maxIndex = desiredLabels.index(limits[3])

        # Convert into DET scale
        pticks = [self.__ppndf__(float(v)) for v in desiredTicks]

        # Plot diagonal line to facilitate reading the EER-value(s) from the plot.
        if self.config.getShowDiagonalInDet():
            plt.plot(pticks, pticks, color='red', lw=1.0, linestyle="-.")

        ax = plt.gca()

        plt.axis([
            pticks[fa_minIndex], pticks[fa_maxIndex], pticks[fr_minIndex],
            pticks[fr_maxIndex]
        ])

        ax.set_yticks(pticks[fr_minIndex:fr_maxIndex])
        ax.set_yticklabels(desiredLabels[fr_minIndex:fr_maxIndex],
                           size='x-small',
                           rotation='horizontal')
        ax.set_xticks(pticks[fa_minIndex:fa_maxIndex])
        ax.set_xticklabels(desiredLabels[fa_minIndex:fa_maxIndex],
                           size='x-small',
                           rotation='vertical')
        if title:
            plt.title("DET plot for '" + self.data.getTitle() + "'")
            plt.grid(True)
            plt.ylabel('False Rejection Rate [%]')
            plt.xlabel('False Acceptance Rate [%]')
        plt.legend(loc=1)
        if self.config.getPrintToFile():
            filename = "%s_%s.%s" % (self._printToFilename, self.plotType,
                                     "png")
            print("Writing plot to %s" % filename)
            plt.savefig(filename, orientation='landscape', papertype='letter')
        else:
            plt.show()