def mpl_linestyle2pgfplots_linestyle(line_style):
    """Translates a line style of matplotlib to the corresponding style
    in PGFPlots.
    """
    if isinstance(line_style, tuple):
        if line_style[0] is None:
            return None
        if len(line_style[1]) == 2:
            return 'dash pattern=on {}pt off {}pt'.format(*line_style[1])
        assert len(line_style[1]) == 4
        return 'dash pattern=on {}pt off {}pt on {}pt off {}pt'.format(*
            line_style[1])
    return {'': None, 'None': None, 'none': None, '-': 'solid', 'solid':
        'solid', ':': 'dotted', '--': 'dashed', '-.':
        'dash pattern=on 1pt off 3pt on 3pt off 3pt'}[line_style]
