Esempio n. 1
0
    def drawBoxPlots(cls, mboxes, methods, nmethods, pdf):
        bl = mboxes.pop("baseline")
        blm = mboxes.pop("baselineMeasures")
        mets = sorted(methods.keys())
        for outliers in ("^", ""):
            nstep = 1
            # compare methods to each other
            ncols = nmethods + 2
            Graph.clf()

            Graph.subplot(1, ncols, nstep)
            d = 1.0 / (2 * len(bl))
            # make sure we iterate with the same order over methods
            for pair, data in bl.iteritems():
                vals = [[], []]
                for me in mets:
                    vals[0].append(data[me][0])
                    vals[1].append(data[me][1])
                Graph.errorbar(
                    [d + i for i in range(1, len(mets) + 1)],
                    vals[0],
                    yerr=vals[1],
                    fmt=".",
                    color=Graph.getColor(pair),
                    label="%s,%s" % pair,
                )
                Graph.hold = True
                d += 1.0 / len(bl)
            for l in range(1, len(mets) + 1):
                Graph.axvspan(
                    l, l + 1, facecolor=Graph.getColor(mets[l - 1]), alpha=0.1, hold=True
                )  # , linestyle = '--')
            Graph.legend(loc=2)
            Graph.xticks(rotation=50)
            Graph.decorate(
                g_xtickslab=[""] + mets,
                g_xticks=[0.5 + i for i in range(0, len(methods) + 1)],
                g_grid=True,
                g_xlabel="Measurement method",
                g_ylabel="Measured delays with stddev (ms)",
                g_title="Baseline for all methods",
            )
            nstep += 1

            Graph.subplot(1, ncols, nstep)
            Graph.boxplot([blm[met] for met in mets], sym=outliers)
            Graph.xticks(rotation=50)
            Graph.decorate(
                g_xtickslab=mets,
                g_grid=True,
                g_xlabel="Measurement method",
                g_ylabel="Measured baseline (ms)",
                g_title="Measures for baseline",
            )
            nstep += 1
            for step in sorted(mboxes.keys()):
                m_datas = mboxes[step]
                Graph.subplot(1, ncols, nstep)
                Graph.xticks(rotation=50)
                Graph.boxplot([m_datas[met] for met in mets], sym=outliers)
                Graph.axhline(2 * step, color="r")
                Graph.decorate(
                    g_xtickslab=mets,
                    g_grid=True,
                    g_xlabel="Measurement method",
                    g_ylabel="Measured delays - baseline (ms)",
                    g_title="Measures for step 2x%sms" % step,
                )
                nstep += 1
            fig = Graph.gcf()
            fig.set_size_inches(28, 8)
            pdf.savefig(bbox_inches="tight")  #'checks/boxdelay.pdf', format = 'pdf', )
            Graph.close()
Esempio n. 2
0
    def drawBoxPlots(cls, mboxes, methods, nmethods, pdf):
        bl = mboxes.pop('baseline')
        blm = mboxes.pop('baselineMeasures')
        mets = sorted(methods.keys())
        for outliers in ('^', ''):
            nstep = 1
            #compare methods to each other
            ncols = nmethods + 2
            Graph.clf()

            Graph.subplot(1, ncols, nstep)
            d = 1.0 / (2 * len(bl))
            # make sure we iterate with the same order over methods
            for pair, data in bl.iteritems():
                vals = [[], []]
                for me in mets:
                    vals[0].append(data[me][0])
                    vals[1].append(data[me][1])
                Graph.errorbar([d + i for i in range(1,
                                                     len(mets) + 1)],
                               vals[0],
                               yerr=vals[1],
                               fmt='.',
                               color=Graph.getColor(pair),
                               label='%s,%s' % pair)
                Graph.hold = True
                d += 1.0 / len(bl)
            for l in range(1, len(mets) + 1):
                Graph.axvspan(l,
                              l + 1,
                              facecolor=Graph.getColor(mets[l - 1]),
                              alpha=0.1,
                              hold=True)  #, linestyle = '--')
            Graph.legend(loc=2)
            Graph.xticks(rotation=50)
            Graph.decorate(
                g_xtickslab=[
                    '',
                ] + mets,
                g_xticks=[0.5 + i for i in range(0,
                                                 len(methods) + 1)],
                g_grid=True,
                g_xlabel='Measurement method',
                g_ylabel='Measured delays with stddev (ms)',
                g_title='Baseline for all methods')
            nstep += 1

            Graph.subplot(1, ncols, nstep)
            Graph.boxplot([blm[met] for met in mets], sym=outliers)
            Graph.xticks(rotation=50)
            Graph.decorate(g_xtickslab=mets,
                           g_grid=True,
                           g_xlabel='Measurement method',
                           g_ylabel='Measured baseline (ms)',
                           g_title='Measures for baseline')
            nstep += 1
            for step in sorted(mboxes.keys()):
                m_datas = mboxes[step]
                Graph.subplot(1, ncols, nstep)
                Graph.xticks(rotation=50)
                Graph.boxplot([m_datas[met] for met in mets], sym=outliers)
                Graph.axhline(2 * step, color='r')
                Graph.decorate(g_xtickslab=mets,
                               g_grid=True,
                               g_xlabel='Measurement method',
                               g_ylabel='Measured delays - baseline (ms)',
                               g_title='Measures for step 2x%sms' % step)
                nstep += 1
            fig = Graph.gcf()
            fig.set_size_inches(28, 8)
            pdf.savefig(
                bbox_inches='tight')  #'checks/boxdelay.pdf', format = 'pdf', )
            Graph.close()