# Path: aqmt/plot/common.py
# 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)
# 
# def add_scale(y_logarithmic, range_from=None, range_from_log=None,
#         range_to=None, range_to_log=None):
#     if y_logarithmic:
#         if range_from_log is None:
#             range_from_log = '1'
#         if range_to_log is None:
#             range_to_log = '*'
#         return """
#             set logscale y
#             set yrange [""" + range_from_log + """:""" + range_to_log + """]
#             """
#     else:
#         if range_from is None:
#             range_from = '0'
#         if range_to is None:
#             range_to = '1<*'
#         return """
#             set yrange [""" + range_from + """:""" + range_to + """]
#             """


from collections import OrderedDict
from .common import add_plot, add_scale
        plot_gpi += "''                                             using ($0+1.05):($2/1000) with lines lc rgb 'gray'         title '', \\\n"
        plot_gpi += "''                                             using ($0+1.05):($10/1000) with points  ls 3 pointtype 1 ps 0.3 lw 1.5 title '', \\\n"
        plot_gpi += "''                                             using ($0+1.05):($4/1000) with points  ls 3 pointtype 1 ps 0.3 lw 1.5 title '', \\\n"
        if show_p75:
            plot_gpi += "''                                         using ($0+1.05):($8/1000) with points  ls 3 pointtype 1 ps 0.3 lw 1.5 title '', \\\n"

        gpi += """
            plot \\
            """ + add_plot(plot_gpi) + """

            unset label
            unset logscale y
            """

        return {
            'gpi': gpi,
        }

    return plot


def drops_marks(y_logarithmic=False, show_total=True):
    def plot(testfolder, plotdef):
        label_y_pos = -0.06 * (1/plotdef.y_scale)
        title = "Packets per sample" if not show_total else \
                "Packets per sample \\n{/Times:Italic=10 Dotted lines are}\\n{/Times:Italic=10 sum dropped and sent}"
        gpi = """
            set format y "%g"
            set ylabel \"""" + title + """\"
            set xtics in mirror

# Path: aqmt/plot/common.py
# 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)
# 
# def add_scale(y_logarithmic, range_from=None, range_from_log=None,
#         range_to=None, range_to_log=None):
#     if y_logarithmic:
#         if range_from_log is None:
#             range_from_log = '1'
#         if range_to_log is None:
#             range_to_log = '*'
#         return """
#             set logscale y
#             set yrange [""" + range_from_log + """:""" + range_to_log + """]
#             """
#     else:
#         if range_from is None:
#             range_from = '0'
#         if range_to is None:
#             range_to = '1<*'
#         return """
#             set yrange [""" + range_from + """:""" + range_to + """]
#             """


# Path: aqmt/plot/flow_components.py
from collections import OrderedDict
from .common import add_plot, add_scale

        plot_gpi += "''                                             using ($0+1.05):($2/1000) with lines lc rgb 'gray'         title '', \\\n"
        plot_gpi += "''                                             using ($0+1.05):($10/1000) with points  ls 3 pointtype 1 ps 0.3 lw 1.5 title '', \\\n"
        plot_gpi += "''                                             using ($0+1.05):($4/1000) with points  ls 3 pointtype 1 ps 0.3 lw 1.5 title '', \\\n"
        if show_p75:
            plot_gpi += "''                                         using ($0+1.05):($8/1000) with points  ls 3 pointtype 1 ps 0.3 lw 1.5 title '', \\\n"

        gpi += """
            plot \\
            """ + add_plot(plot_gpi) + """

            unset label
            unset logscale y
            """

        return {
            'gpi': gpi,
        }

    return plot


def drops_marks(y_logarithmic=False, show_total=True):
    def plot(testfolder, plotdef):
        label_y_pos = -0.06 * (1/plotdef.y_scale)
        title = "Packets per sample" if not show_total else \
                "Packets per sample \\n{/Times:Italic=10 Dotted lines are}\\n{/Times:Italic=10 sum dropped and sent}"
        gpi = """
            set format y "%g"
            set ylabel \"""" + title + """\"
            set xtics in mirror

            """ + add_scale(y_logarithmic, range_from_log='0.9', range_to='10<*') + """