From 513589a75ff32b44df9c36d5cb9e57f2ae64aeef Mon Sep 17 00:00:00 2001 From: Sietze van Buuren Date: Sat, 9 Nov 2024 11:07:53 +0100 Subject: [PATCH] feat: Add arctan2 example Signed-off-by: Sietze van Buuren --- examples/arctan2.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 examples/arctan2.py diff --git a/examples/arctan2.py b/examples/arctan2.py new file mode 100644 index 0000000..f584bec --- /dev/null +++ b/examples/arctan2.py @@ -0,0 +1,27 @@ +""" +Surface plot of arctan2 function +""" + +import numpy as np +import mlpyqtgraph as mpg + + +@mpg.plotter(antialiasing=True) +def main(): + """ Examples with surface plots """ + extent = 4 + nx = 48 + ny = 48 + amplitude = 0.5 + x = np.linspace(-extent, extent, nx) + y = np.linspace(-extent, extent, ny) + z = np.zeros((nx, ny)) + for i in range(ny): + z[i, :] = amplitude * np.arctan2(x, y[i]) + + mpg.figure(title='arctan2(x, y)', layout_type='Qt') + mpg.surf(x, y, z, colormap='viridis', projection='orthographic') + + +if __name__ == '__main__': + main()