plot_template.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. def make_plot_ships_script(priority:str, strategy:str, max_waits:list[float], gen_num:int):
  2. return (f"""
  3. ### priority={priority}, strategy={strategy} ###
  4. set terminal svg
  5. # plot 1. x-axis: ships, y-axis: queuing duration of ship
  6. set out 'plot_ships_{strategy}_{priority}.svg'
  7. set title "Queueing duration"
  8. set xlabel "Ship #"
  9. set ylabel "Seconds"
  10. #unset xlabel
  11. #unset xtics
  12. set key title "Max Wait"
  13. set key bottom center out
  14. set key horizontal
  15. """
  16. # + '\n'.join([
  17. # f"set style line {i+1} lw 4"
  18. # for i in range(len(max_waits))
  19. # ])
  20. + f"""
  21. # set yrange [0:90000]
  22. set xrange [0:{gen_num}]
  23. set style fill solid
  24. plot 'output_{strategy}_{priority}.csv' \\\n """ + ", \\\n '' ".join([
  25. f"using 1:{i+1} title '{max_wait}' w boxes ls {i+1}"
  26. for i, max_wait in enumerate(max_waits)
  27. ]))
  28. def make_plot_box_script(priority:str, strategy:str, max_waits:list[float], gen_num:int):
  29. return (f"""
  30. # plot 2. x-axis: max-wait parameter, y-axis: queueing durations of ships
  31. set out 'plot_box_{strategy}_{priority}.svg'
  32. set style fill solid 0.25 border -1
  33. set style boxplot outliers pointtype 7
  34. set style data boxplot
  35. set key off
  36. set xlabel "Max Wait"
  37. unset xrange
  38. unset yrange
  39. set xtics (""" + ', '.join([ f"'{max_wait}' {i}"
  40. for i, max_wait in enumerate(max_waits)]) + f""")
  41. plot 'output_{strategy}_{priority}.csv' \\\n """ + ", \\\n '' ".join([
  42. f"using ({i}):{i+2} title '{max_wait}'"
  43. for i, max_wait in enumerate(max_waits)
  44. ]))