diff --git a/lukovnikovde/docs/data/DataStructure.py b/lukovnikovde/docs/data/DataStructure.py index 32e6ab5..f84bcff 100644 --- a/lukovnikovde/docs/data/DataStructure.py +++ b/lukovnikovde/docs/data/DataStructure.py @@ -26,13 +26,18 @@ def file_insert(results): writer = csv.writer(file) writer.writerows(results) -def drow(time, color_fun): - x = [] +def drow(time, color_fun, j, text, axes): + + operation = [0, 1, 2, 3] + x = [j + operation[i] for i in range(4)] y = [] for key in time: - x.append(key) y.append(time[key] * 1000) - plt.plot(x, y, marker = ".", color = color_fun, markersize = 2, alpha = 0.9) + for i in range(4): + axes[i].bar(x[i], y[i], width = 0.12, color = color_fun, label = text) + axes[i].set_ylabel("Время, мс") + axes[i].set_xticks([]) + #plt.bar(x, y, width = 0.12, color = color_fun, label = text) @@ -470,23 +475,27 @@ def main(): results[i][3] *= 1000 file_insert(results) - plt.figure(figsize = (16, 9)) - plt.xlabel("Операция") - plt.ylabel("Время мс") + fig, axes = plt.subplots(1, 4, figsize = (16, 5)) + manager = plt.get_current_fig_manager() + manager.full_screen_toggle() - drow(Time_average_ll_not_sorted, "blue") - drow(Time_average_ll_sorted, "green") - drow(Time_average_ht_not_sorted, "#FF8800") - drow(Time_average_ht_sorted, "#FF0000") - drow(Time_average_bst_not_sorted, "#464219") - drow(Time_average_bst_sorted, "#FBFF00") - text = """ - синий - LinkedList (not sorted) ораньжевый - HashTable (not sorted) коричневый - BST (not sorted) - зеленый - LinkedList (sorted) красный - HashTable (sorted) желтый - BST (sorted) - """ - # plt.subplots_adjust(bottom =0.3) - plt.figtext(0.1, 0.02, text, wrap = True, fontsize = 9, va = 'bottom') + drow(Time_average_ll_not_sorted, "#0800FF", -0.3, "LinkedList (not sorted)", axes) + drow(Time_average_ll_sorted, "#00C8FF", -0.18, "LinkedList (sorted)", axes) + drow(Time_average_ht_not_sorted, "#0E7A13", -0.06, "HashTable (not sorted)", axes) + drow(Time_average_ht_sorted, "#4DFF00", 0.06, "HashTable (sorted)", axes) + drow(Time_average_bst_not_sorted, "#968C1A", 0.18, "BST (not sorted)", axes) + drow(Time_average_bst_sorted, "#FBFF00", 0.30, "BST (sorted)", axes) + + operation = ['insert', 'find', 'delete', 'create list'] + + for i in range(4): + axes[i].set_title(operation[i]) + plt.legend(bbox_to_anchor = (1.05, 1), loc = "upper left") + + + + plt.subplots_adjust(bottom = 0.025, top = 0.95, left = 0.025, right = 0.875) plt.savefig("time_schedule.png") plt.show()