Advertisement
MdSadmanSiraj

two_vertical_axis_plot.py

Feb 9th, 2023
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.24 KB | None | 0 0
  1. dist_final = [16.5173085362052, 14.876963985727059, 10.934011884128024, 8.358418078054424]
  2. system_error = [270.2912193825012, 440.3120792030492, 542.04230576983235, 669.4479629830983]
  3.  
  4. dist_final = [round(item, 2) for item in dist_final]
  5. system_error = [round(item, 2) for item in system_error]
  6. game_rounds = [46, 29, 24, 20]
  7.  
  8. labels = ['Var=5', 'Var=4', 'Var=3', 'Var=2']
  9.  
  10. fig, error_axis = plt.subplots()
  11. x = np.arange(len(labels))
  12.  
  13. distance_axis = error_axis.twinx()
  14. round_axis = error_axis.twinx()
  15. round_axis.spines.right.set_position(("axes", 1.13))
  16.  
  17. width = 0.20
  18. barSpace = 0.40
  19.  
  20. # color=['firebrick','red','darksalmon','darkblue','blue','royalblue']
  21. # width = 0.1
  22. p1 = error_axis.bar(x - width, np.log(system_error), width=width, color='red', align='center', label=r'$\eta_{ER,h}$')
  23. p2 = distance_axis.bar(x, dist_final, width=width, color='green', align='center', label=r'$\eta_{ER,h}$')
  24. p3 = round_axis.bar(x + width, game_rounds, width=width, color='mediumblue', align='center', label=r'$\eta_{ER,h}$')
  25.  
  26. error_axis.yaxis.label.set_color("red")
  27. distance_axis.yaxis.label.set_color("green")
  28. round_axis.yaxis.label.set_color("mediumblue")
  29.  
  30. tkw = dict(size=4, width=1.5)
  31. error_axis.tick_params(axis='y', colors="red", **tkw)
  32. distance_axis.tick_params(axis='y', colors="green", **tkw)
  33. round_axis.tick_params(axis='y', colors="mediumblue", **tkw)
  34. error_axis.tick_params(axis='x', **tkw)
  35.  
  36. # lns = [p1, p2, p3]
  37. # distance_axis.legend(handles=lns, loc='best')
  38.  
  39. # ax3.spines['right'].set_position(('outward', 60))  
  40. # ax3.xaxis.set_ticks([])
  41.  
  42. error_axis.set_xticks(x)
  43. error_axis.set_xticklabels(labels)
  44.  
  45. error_axis.set_xlabel("Number of Variables", fontsize = 24)
  46. error_axis.set_ylabel("$ln$ [Overall Error Distance]", fontsize = 24)
  47. distance_axis.set_ylabel("Users' Avg. Dist. from Soc. Com.", fontsize = 24)
  48. round_axis.set_ylabel("Game Rounds", fontsize = 24)
  49.  
  50. error_axis.set_ylim(5, 6.6)
  51. round_axis.set_ylim(10.0, 50)
  52.  
  53. # plt.text(0.03, 0.95, '(f)', transform=error_axis.transAxes, fontsize=26, fontweight='bold', va='top')
  54. # plt.savefig("graphs_v3/comparative_results/2_f.png", format='png', bbox_inches='tight', dpi=720)
  55. # plt.savefig("graphs_v3/comparative_results/2_f.eps", format='eps', bbox_inches='tight', dpi=720)
  56. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement