From 14a46d6057d64c8e621aa3eaed444570cde8be91 Mon Sep 17 00:00:00 2001 From: Janita Willumsen Date: Tue, 12 Sep 2023 20:59:34 +0200 Subject: [PATCH] Fix legend format --- src/plot_general_alg.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/plot_general_alg.py b/src/plot_general_alg.py index 903ac67..c4dd455 100644 --- a/src/plot_general_alg.py +++ b/src/plot_general_alg.py @@ -4,6 +4,7 @@ import numpy as np analytical_func = lambda x: 1 - (1 - np.exp(-10))*x - np.exp(-10*x) def main(): + fig, ax = plt.subplots() for i in range(6): x = [] y = [] @@ -19,12 +20,12 @@ def main(): x.append(1.) y.append(0.) - plt.plot(x, y, label=f"n_steps={10**(i+1)}") + ax.plot(x, y, label=f"n$_{{steps}} = 10^{i+1}$") x = np.linspace(0, 1, 1001) - plt.plot(x, analytical_func(x), label="analytical plot") - plt.legend() - plt.savefig("../latex/images/problem7.pdf") + ax.plot(x, analytical_func(x), label=f"u$_{{exact}}$") + ax.legend() + fig.savefig("../latex/images/problem7.pdf") if __name__ == "__main__": main()