def buildTitle(dat, xName, yName):
    """ Build plot title.

    :Arguments:
        :type dat: interface.wideToDesign
        :param dat: A wide to design object

        :type xName: string
        :param xName: String containing the sampleID for x

        :type yName: string
        :param yName: String containing the sampleID for y

    :Returns:
        :rtype: string
        :returns: A string containing the plot title.
    """
    # If groups are the same, add group information to the plot.
    if dat.group and dat.design.loc[xName, dat.group] == dat.design.loc[yName, dat.group]:
        group = dat.design.loc[xName, dat.group]
        title = '{0}\n{1} vs {2}'.format(group, xName, yName)
    else:
        title = '{0} vs {1}'.format(xName, yName)

    # If there are missing values add the count to the title.
    try:
        if dat.missing == 1:
            title = title + '\n1 missing value'
        elif dat.missing > 0:
            title = title + '\n{} missing values'.format(dat.missing)
    except:
        pass

    return title