<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def plot(self, sig_style='', title=None, figsize=None, return_fig=False):
 """ Plot the comparison of two sets of annotations, possibly overlaid on their original signal. Parameters sig_style : str, optional The matplotlib style of the signal title : str, optional The title of the plot figsize: tuple, optional Tuple pair specifying the width, and height of the figure. It is the'figsize' argument passed into matplotlib.pyplot's `figure` function. return_fig : bool, optional Whether the figure is to be returned as an output argument. """

        fig = plt.figure(figsize=figsize)
        ax = fig.add_subplot(1, 1, 1)

        legend = ['Signal',
                  'Matched Reference Annotations (%d/%d)' % (self.tp, self.n_ref),
                  'Unmatched Reference Annotations (%d/%d)' % (self.fn, self.n_ref),
                  'Matched Test Annotations (%d/%d)' % (self.tp, self.n_test),
                  'Unmatched Test Annotations (%d/%d)' % (self.fp, self.n_test)
        ]

        # Plot the signal if any
        if self.signal is not None:
            ax.plot(self.signal, sig_style)

            # Plot reference annotations
            ax.plot(self.matched_ref_sample,
                    self.signal[self.matched_ref_sample], 'ko')
            ax.plot(self.unmatched_ref_sample,
                    self.signal[self.unmatched_ref_sample], 'ko',
                    fillstyle='none')
            # Plot test annotations
            ax.plot(self.matched_test_sample,
                    self.signal[self.matched_test_sample], 'g+')
            ax.plot(self.unmatched_test_sample,
                    self.signal[self.unmatched_test_sample], 'rx')

            ax.legend(legend)

        # Just plot annotations
        else:
           # Plot reference annotations
            ax.plot(self.matched_ref_sample, np.ones(self.tp), 'ko')
            ax.plot(self.unmatched_ref_sample, np.ones(self.fn), 'ko',
                fillstyle='none')
            # Plot test annotations
            ax.plot(self.matched_test_sample, 0.5 * np.ones(self.tp), 'g+')
            ax.plot(self.unmatched_test_sample, 0.5 * np.ones(self.fp), 'rx')
            ax.legend(legend[1:])

        if title:
            ax.set_title(title)

        ax.set_xlabel('time/sample')

        fig.show()

        if return_fig:
            return fig, ax