.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "tutorials/plot_layer.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. or to run this example in your browser via Binder .. rst-class:: sphx-glr-example-title .. _sphx_glr_tutorials_plot_layer.py: Plotting layers =============== Vizualizing a layer pattern in 2D with matplotlib. .. GENERATED FROM PYTHON SOURCE LINES 14-21 .. code-block:: Python import matplotlib.pyplot as plt import nannos as nn .. GENERATED FROM PYTHON SOURCE LINES 23-24 Let's define our lattice: .. GENERATED FROM PYTHON SOURCE LINES 24-36 .. code-block:: Python lat = nn.Lattice(basis_vectors=[[1, 0], [0, 1]], discretization=2**9) epsilon = 6 * lat.ones() hole = lat.circle(center=(0.5, 0.5), radius=0.2) epsilon[hole] = 1 lay = lat.Layer(name="metasurface", thickness=0.2, epsilon=epsilon) lay.plot() plt.show() .. image-sg:: /tutorials/images/sphx_glr_plot_layer_001.png :alt: plot layer :srcset: /tutorials/images/sphx_glr_plot_layer_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 37-38 Another lattice with non orthogonal basis vectors: .. GENERATED FROM PYTHON SOURCE LINES 38-52 .. code-block:: Python lat = nn.Lattice(basis_vectors=[[1, 0], [0.5, 0.5]], discretization=2**9) epsilon = lat.ones() scat = lat.ellipse(center=(0.75, 0.25), radii=(0.4, 0.1), rotate=15) epsilon[scat] = 3 - 1j lay = lat.Layer(name="grating", thickness=1.3, epsilon=epsilon) ims = lay.plot(nper=(3, 2), show_cell=True, cmap="Greens", comp="im", cellstyle="y--") plt.axis("off") plt.colorbar(ims[0], orientation="horizontal") plt.title(r"${\rm Im}\,\varepsilon$") plt.tight_layout() plt.show() .. image-sg:: /tutorials/images/sphx_glr_plot_layer_002.png :alt: ${\rm Im}\,\varepsilon$ :srcset: /tutorials/images/sphx_glr_plot_layer_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 1.907 seconds) **Estimated memory usage:** 519 MB .. _sphx_glr_download_tutorials_plot_layer.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: binder-badge .. image:: images/binder_badge_logo.svg :target: https://mybinder.org/v2/gh/nannos/nannos.gitlab.io/doc?filepath=notebooks/tutorials/plot_layer.ipynb :alt: Launch binder :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_layer.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_layer.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_layer.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_