| 148 | Draw plot using Matplotlib |
| 149 | """ |
| 150 | def draw_plot_func(dictionary, n_classes, window_title, plot_title, y_label, output_path, to_show): |
| 151 | # sort the dictionary by decreasing value (reverse=True), into a list of tuples |
| 152 | sorted_dic_by_value = sorted(dictionary.items(), key=operator.itemgetter(1), reverse=True) |
| 153 | # unpacking the list of tuples into two lists |
| 154 | sorted_keys, sorted_values = zip(*sorted_dic_by_value) |
| 155 | plt.bar(range(n_classes), sorted_values, align='center') |
| 156 | plt.xticks(range(n_classes), sorted_keys, rotation='vertical') |
| 157 | # set window title |
| 158 | fig = plt.gcf() # gcf - get current figure |
| 159 | fig.canvas.set_window_title(window_title) |
| 160 | # set plot title |
| 161 | plt.title(plot_title) |
| 162 | # set axis titles |
| 163 | # plt.xlabel('classes') |
| 164 | plt.ylabel(y_label) |
| 165 | # adjust size of window |
| 166 | fig.tight_layout() |
| 167 | if to_show: |
| 168 | plt.show() |
| 169 | # save the plot |
| 170 | fig.savefig(output_path) |
| 171 | # clear the plot |
| 172 | plt.clf() |
| 173 | |
| 174 | """ |
| 175 | Create a "tmp_files/" and "results/" directory |