import re


def add_plot(gpi):
    """
    Remove trailing comma from plot command because gnuplot complains about it
    (We use the trailing comma to easier build plot commands)
    """
    return re.sub(r',(\s*\\?\s*\\?\s*)$', '\g<1>', gpi)