From ad0e3d49ebffc516a81142d228ea571f4df324a2 Mon Sep 17 00:00:00 2001 From: Aayush Badoni Date: Sun, 31 Mar 2024 05:16:14 +0530 Subject: [PATCH 1/2] added a sample lecture for matplot lib --- _sources/poc/_static/component.html | 26 +++++++++++++++ _sources/poc/matplotlib.rst | 50 +++++++++++++++++++++++++++++ build_info | 1 + 3 files changed, 77 insertions(+) create mode 100644 _sources/poc/_static/component.html create mode 100644 _sources/poc/matplotlib.rst create mode 100644 build_info diff --git a/_sources/poc/_static/component.html b/_sources/poc/_static/component.html new file mode 100644 index 0000000000..d4d5829388 --- /dev/null +++ b/_sources/poc/_static/component.html @@ -0,0 +1,26 @@ +
+ +
diff --git a/_sources/poc/matplotlib.rst b/_sources/poc/matplotlib.rst new file mode 100644 index 0000000000..19d2e3bc83 --- /dev/null +++ b/_sources/poc/matplotlib.rst @@ -0,0 +1,50 @@ +======================== +MatPlotLib Demonstration +======================== + +This is a demonstartion to show how to use MatPlotLib to create a simple plot. +This plot is implemented in the browser using the PyScript Component I submitted in a previous PR. + +.. code:: python + + import matplotlib.pyplot as plt + import matplotlib.tri as tri + import numpy as np + + # First create the x and y coordinates of the points. + n_angles = 36 + n_radii = 8 + min_radius = 0.25 + radii = np.linspace(min_radius, 0.95, n_radii) + + angles = np.linspace(0, 2 * np.pi, n_angles, endpoint=False) + angles = np.repeat(angles[..., np.newaxis], n_radii, axis=1) + angles[:, 1::2] += np.pi / n_angles + + x = (radii * np.cos(angles)).flatten() + y = (radii * np.sin(angles)).flatten() + z = (np.cos(radii) * np.cos(3 * angles)).flatten() + + # Create the Triangulation; no triangles so Delaunay triangulation created. + triang = tri.Triangulation(x, y) + + # Mask off unwanted triangles. + triang.set_mask(np.hypot(x[triang.triangles].mean(axis=1), + y[triang.triangles].mean(axis=1)) + < min_radius) + + fig1, ax1 = plt.subplots() + ax1.set_aspect('equal') + tpc = ax1.tripcolor(triang, z, shading='flat') + fig1.colorbar(tpc) + ax1.set_title('tripcolor of Delaunay triangulation, flat shading') + + display(fig1) + +Instructions +------------ +Run the code in the notebook below by ``Shift + Enter``. +The plot will be displayed below the code cell. + +.. raw:: html + :file: ./_static/component.html \ No newline at end of file diff --git a/build_info b/build_info new file mode 100644 index 0000000000..1d0fe84223 --- /dev/null +++ b/build_info @@ -0,0 +1 @@ +unknown-0-0 From acd586a364ca132935f600af6bb118f884c434f4 Mon Sep 17 00:00:00 2001 From: Aayush Badoni Date: Sun, 31 Mar 2024 05:28:32 +0530 Subject: [PATCH 2/2] removed unecessary file --- build_info | 1 - 1 file changed, 1 deletion(-) delete mode 100644 build_info diff --git a/build_info b/build_info deleted file mode 100644 index 1d0fe84223..0000000000 --- a/build_info +++ /dev/null @@ -1 +0,0 @@ -unknown-0-0