aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/scripts/plot_all.sh
diff options
context:
space:
mode:
authorEgor Tensin <egor@tensin.name>2026-06-06 21:45:45 +0200
committerEgor Tensin <egor@tensin.name>2026-06-06 21:45:45 +0200
commitfba834a617d2d2905cfc84595de100f8a5368c0a (patch)
tree2b629a72dacfec75a6cf28a298ff309602cfff5d /scripts/plot_all.sh
parentworkflows/ci: remove on: pull_request (diff)
downloadsorting-algorithms-fba834a617d2d2905cfc84595de100f8a5368c0a.tar.gz
sorting-algorithms-fba834a617d2d2905cfc84595de100f8a5368c0a.zip
sort out scripts into proper directories
Diffstat (limited to 'scripts/plot_all.sh')
-rwxr-xr-xscripts/plot_all.sh46
1 files changed, 46 insertions, 0 deletions
diff --git a/scripts/plot_all.sh b/scripts/plot_all.sh
new file mode 100755
index 0000000..1e56f40
--- /dev/null
+++ b/scripts/plot_all.sh
@@ -0,0 +1,46 @@
+#!/usr/bin/env bash
+
+# Copyright (c) 2019 Egor Tensin <Egor.Tensin@gmail.com>
+# This file is part of the "Sorting algorithms" project.
+# For details, see https://github.com/egor-tensin/sorting-algorithms.
+# Distributed under the MIT License.
+
+set -o errexit -o nounset -o pipefail
+shopt -s inherit_errexit lastpipe
+
+script_dir="$( dirname -- "${BASH_SOURCE[0]}" )"
+script_dir="$( cd -- "$script_dir" && pwd )"
+readonly script_dir
+
+declare -a algorithm_list=(
+ bubble_sort
+ bubble_sort_optimized
+ heapsort
+ insertion_sort
+ merge_sort
+ quicksort_first
+ quicksort_last
+ quicksort_middle
+ quicksort_random
+ quicksort_second
+ selection_sort
+)
+
+fix_matplotlib() {
+ # Get rid of:
+ # tkinter.TclError: no display name and no $DISPLAY environment variable
+ mkdir -p -- ~/.config/matplotlib
+ echo 'backend: Agg' > ~/.config/matplotlib/matplotlibrc
+}
+
+main() {
+ fix_matplotlib
+
+ local algorithm
+ for algorithm in ${algorithm_list[@]+"${algorithm_list[@]}"}; do
+ echo "Plotting algorithm $algorithm..."
+ "$script_dir/plot.sh" "$algorithm"
+ done
+}
+
+main "$@"