From 0d118c4650e2be8c3405063ea173e50c3da9cfa9 Mon Sep 17 00:00:00 2001 From: Daniel Shapero Date: Thu, 29 Jun 2023 11:52:19 -0700 Subject: [PATCH] Added function to make plots of LBB stability --- demo/lbb-stability/make_plots.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 demo/lbb-stability/make_plots.py diff --git a/demo/lbb-stability/make_plots.py b/demo/lbb-stability/make_plots.py new file mode 100644 index 0000000..4087fc0 --- /dev/null +++ b/demo/lbb-stability/make_plots.py @@ -0,0 +1,25 @@ +import json +import argparse +import numpy as np +import matplotlib.pyplot as plt + +parser = argparse.ArgumentParser() +parser.add_argument("--input") +parser.add_argument("--output") +args = parser.parse_args() + +with open(args.input, "r") as input_file: + data = json.load(input_file) + +fig, ax = plt.subplots() +ax.set_title("Empirical inf-sup constants") +ax.set_xscale("log", base=2) +ax.set_ylim((0.0, 1.0)) +ax.set_xlabel("Mesh spacing") +ax.set_ylabel("inf-sup constant") +for entry in data: + element = entry["element"] + hs, λs = zip(*entry["results"]) + ax.scatter(hs, λs, label=element) +ax.legend() +fig.savefig(args.output, bbox_inches="tight")