(*rewards, labels=None, colors=None, ax=None)
| 93 | |
| 94 | |
| 95 | def reward_compare_plot(*rewards, labels=None, colors=None, ax=None): |
| 96 | if ax is None: |
| 97 | ax = plt.gca() |
| 98 | for i, w in enumerate(rewards): |
| 99 | range_plot(w, color=colors[i] if colors else f'C{i}', label=labels[i] if labels else None) |
| 100 | |
| 101 | ax.axhline(500, color='gray', linestyle='--', |
| 102 | label='max reward', alpha=0.5) |
| 103 | ax.legend(fontsize='small') |
| 104 | ax.set_ylim(5, 570) |
| 105 | # ax.set_xlim(None, len(rewards[0])) |
| 106 | ax.set_xlabel('generation') |
| 107 | ax.set_ylabel('reward') |
| 108 | |
| 109 | # set x-axis ticks with 2, 4, 6, 8, 10 |
| 110 | ax.set_xticks([2, 4, 6, 8, 10]) |
| 111 | ax.set_xticklabels([f'{tick}' for tick in [2, 4, 6, 8, 10]]) |
| 112 | |
| 113 | # set y-axis as reversed log scale |
| 114 | ax.set_yscale('log') |
| 115 | |
| 116 | major_ticks = [10, 100, 300, 500] |
| 117 | plt.yticks(major_ticks, [f'{tick}' for tick in major_ticks]) |
| 118 | |
| 119 | # Set the minor ticks locator and formatter |
| 120 | ax.yaxis.set_minor_locator(LogLocator(base=10.0, subs='auto', numticks=10)) |
| 121 | ax.yaxis.set_minor_formatter(LogFormatter(base=10.0, labelOnlyBase=False)) |
| 122 | |
| 123 | |
| 124 | def latent_plot(z, ax, color=None, alpha=1, label=None, zorder=1): |
no test coverage detected