From 501f25468f021778e5a7d98b069c2f23a8e32825 Mon Sep 17 00:00:00 2001 From: Lukas Winkler Date: Wed, 13 Feb 2019 12:53:29 +0100 Subject: [PATCH] try out plotting a 2d function --- sinus.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 sinus.py diff --git a/sinus.py b/sinus.py new file mode 100644 index 0000000..5e909c7 --- /dev/null +++ b/sinus.py @@ -0,0 +1,25 @@ +import numpy as np +from matplotlib import pyplot as plt + + +def func(x, y): + return (np.sin(y) + np.sin(x) + 1) / 3 + + +xs = np.linspace(-15, 15, 30) +ys = np.linspace(-15, 15, 300) + +res = [] +for y in ys: + rererere = [] + for x in xs: + rererere.append(func(x, y)) + res.append(rererere) + +data = np.asarray(res) + +# plt.contourf(xs, ys, data, 100, cmap="Blues", vmin=0, vmax=1) +plt.pcolormesh(xs, ys, data, cmap="Blues", vmin=0, vmax=1) +plt.colorbar() + +plt.show()