-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot_graphs.py
More file actions
32 lines (23 loc) · 1.23 KB
/
plot_graphs.py
File metadata and controls
32 lines (23 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import matplotlib.pyplot as plt
import numpy as np
def plot_barplots(median_times, queries):
query_labels = ['Q1', 'Q2', 'Q3', 'Q4']
libraries = ['Pandas', 'PostgreSQL', 'SQLite','SQLAlchemy','DuckDB']
# Данные для построения графика
data = np.array([[median_times[library][i] for library in libraries] for i in range(len(queries))])
# Создание вертикальных барплотов
fig, ax = plt.subplots(figsize=(12, 8))
bar_width = 0.15
bar_positions = np.arange(len(query_labels))
for i, library in enumerate(libraries):
ax.bar(bar_positions + i * bar_width, data[:, i], width=bar_width, label=library)
# Добавление значений времени выполнения на график
for i, library in enumerate(libraries):
for j, query_label in enumerate(query_labels):
ax.text(bar_positions[j] + i * bar_width, data[j, i] + 0.005,
f'{data[j, i]:.2f}', ha='center', va='bottom', fontsize=8)
ax.set_xticks(bar_positions + (len(libraries) - 1) * bar_width / 2)
ax.set_xticklabels(query_labels)
ax.set_ylabel('Median Execution Time (seconds)')
ax.legend(loc='upper left')
plt.show()