diff --git a/latency.py b/latency.py index 3208383..b30bba3 100644 --- a/latency.py +++ b/latency.py @@ -22,7 +22,7 @@ def parse_args(): def one_file_run(): csv_file = parse_args().file - path_splitted = csv_file.split('/') + path_splitted = csv_file.split(os.sep) title = path_splitted[len(path_splitted) - 1].split('.')[0] print("АНАЛИЗ ДОВЕРИТЕЛЬНЫХ ИНТЕРВАЛОВ ДЛЯ ЗАДЕРЖЕК") print("=" * 50) @@ -64,13 +64,13 @@ def validate_csv_list(csv_arr: list, dirConfig: dict) -> bool: def dir_run(): dirConfig = None - with open(parse_args().file + '/dir.yml') as f: + with open(parse_args().file + os.sep + 'dir.yml', encoding='utf-8') as f: dirConfig = yaml.safe_load(f) if dirConfig is None: raise Exception("File not found or not loaded") - - title = parse_args().file.split('/')[1] - all_csv_in_dir = glob.glob(parse_args().file + '/*.csv') + path_separated = parse_args().file.split(os.sep) + title = path_separated[len(path_separated) - 2] + all_csv_in_dir = glob.glob(parse_args().file + os.sep +'*.csv') logging.info(f"Found {len(all_csv_in_dir)} csv files in directory {parse_args().file}") lDataArr = {os.path.basename(file): LatencyData(file) for file in all_csv_in_dir} @@ -88,6 +88,8 @@ def dir_run(): if __name__ == "__main__": + import matplotlib.pyplot as plt + plt.rcParams['font.family'] = 'Arial' args = parse_args() mode = args.mode if mode == 0: diff --git a/latencyPlots.py b/latencyPlots.py index 29f3d56..6fd43a2 100644 --- a/latencyPlots.py +++ b/latencyPlots.py @@ -83,7 +83,7 @@ def plot_horizontal_hist_with_ci(latencies : dict, colors: dict, labels: dict, s key is a filename, value is a string label """ - plt.rcParams.update({'font.size': 14}) + plt.rcParams.update({'font.size': 18}) # Создание гистограммы fig, ax = plt.subplots(figsize=(12,6)) @@ -97,9 +97,13 @@ def plot_horizontal_hist_with_ci(latencies : dict, colors: dict, labels: dict, s # sorting of all arrays to have same order of elements bar_colors = [colors[key] for key in keys] bar_labels = [labels[key] for key in keys] + bar_mlabels = [] + for key in keys: + bar_mlabels.append(f"{latencies[key].mean_delay:.5g}±{latencies[key].std_error:.3g}") - ax.barh(y_idx, medians, xerr=errors, color=bar_colors, capsize=15, align='center') - + logging.info(bar_mlabels) + cont = ax.barh(y_idx, medians, xerr=errors, color=bar_colors, capsize=15, align='center') + ax.bar_label(cont, labels=bar_mlabels, label_type='center') logging.info(f"y_idx={y_idx}; bar_labels={bar_labels}") ax.set_yticks(y_idx, bar_labels) ax.set_xlabel('Задержка (мс)') @@ -136,7 +140,7 @@ def plot_point_cloud(latencies : dict, """ - plt.rcParams.update({'font.size': 14}) + plt.rcParams.update({'font.size': 16}) # Создание гистограммы fig, ax = plt.subplots(figsize=(10,8)) @@ -167,7 +171,7 @@ def plot_point_cloud(latencies : dict, point_ld[i].ci_upper, alpha=0.2, color=point_colors[i]) - ax.legend(ncol=3,bbox_to_anchor=(0.75, 1.1), fancybox=True) + ax.legend(ncol=3,bbox_to_anchor=(0.95, 1.1), fancybox=True) ax.set_xlabel('Время (секунды)') ax.set_ylabel('Задержка (мс)')