# 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
            set arrow 100 from graph 0, first 100 to graph 1, first 100 nohead ls 100 back

            set label "Sample #:" at graph -0.01, graph """ + str(label_y_pos) + """ font 'Times-Roman,11pt' tc rgb 'black' right
            """

        if flows:
            gpi += """
                stats '""" + testfolder + """/derived/util_tagged' using 1 nooutput
                """

        gpi += """
            # make sure stats is run before logscale is set
            """ + add_scale(y_logarithmic, range_to='100<*', range_to_log='105') + """
            """

        # add hidden line to force autoscaling if using logarithimic plot without any points
        plot_gpi = " 1 lc rgb '#FFFF0000' notitle, \\\n"

        if total:
            plot_gpi += "'" + testfolder + "/derived/util'    using ($0+1):($2*100)   with lines ls 1 lw 1.5 title 'Total utilization', \\\n"

        if ecn:
            plot_gpi += "''                                   using ($0+1):($3*100)   with lines ls 2 lw 1.5 title 'ECN utilization', \\\n"
            plot_gpi += "''                                   using ($0+1):($4*100)   with lines ls 3 lw 1.5 title 'Non-ECN utilization', \\\n"

        if flows:
            plot_gpi += "for [IDX=0:STATS_blocks-1] '" + testfolder + "/derived/util_tagged' index IDX using ($1+1):($2*100) with lines ls (IDX+3) title columnheader(1), \\\n"

        gpi += """
            plot \\

# 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

            set arrow 100 from graph 0, first 100 to graph 1, first 100 nohead ls 100 back

            set label "Sample #:" at graph -0.01, graph """ + str(label_y_pos) + """ font 'Times-Roman,11pt' tc rgb 'black' right
            """

        if flows:
            gpi += """
                stats '""" + testfolder + """/derived/util_tagged' using 1 nooutput
                """

        gpi += """
            # make sure stats is run before logscale is set
            """ + add_scale(y_logarithmic, range_to='100<*', range_to_log='105') + """
            """

        # add hidden line to force autoscaling if using logarithimic plot without any points
        plot_gpi = " 1 lc rgb '#FFFF0000' notitle, \\\n"

        if total:
            plot_gpi += "'" + testfolder + "/derived/util'    using ($0+1):($2*100)   with lines ls 1 lw 1.5 title 'Total utilization', \\\n"

        if ecn:
            plot_gpi += "''                                   using ($0+1):($3*100)   with lines ls 2 lw 1.5 title 'ECN utilization', \\\n"
            plot_gpi += "''                                   using ($0+1):($4*100)   with lines ls 3 lw 1.5 title 'Non-ECN utilization', \\\n"

        if flows:
            plot_gpi += "for [IDX=0:STATS_blocks-1] '" + testfolder + "/derived/util_tagged' index IDX using ($1+1):($2*100) with lines ls (IDX+3) title columnheader(1), \\\n"

        gpi += """
            plot \\

            """ + add_plot(plot_gpi) + """