.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/spatial/ctx_2n.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 .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_spatial_ctx_2n.py: Spatial networks: 4x3 grid with pyramidal cells and interneurons ---------------------------------------------------------------- .. only:: html ---- Run this example as a Jupyter notebook: .. card:: :width: 25% :margin: 2 :text-align: center :link: https://lab.ebrains.eu/hub/user-redirect/git-pull?repo=https%3A%2F%2Fgithub.com%2Fnest%2Fnest-simulator-examples&urlpath=lab%2Ftree%2Fnest-simulator-examples%2Fnotebooks%2Fnotebooks%2Fspatial%2Fctx_2n.ipynb&branch=main :link-alt: JupyterHub service .. image:: https://nest-simulator.org/TryItOnEBRAINS.png .. grid:: 1 1 1 1 :padding: 0 0 2 0 .. grid-item:: :class: sd-text-muted :margin: 0 0 3 0 :padding: 0 0 3 0 :columns: 4 See :ref:`our guide ` for more information and troubleshooting. ---- Create a 4x3 grid with one pyramidal cell and one interneuron at each position. BCCN Tutorial @ CNS*09 Hans Ekkehard Plesser, UMB .. GENERATED FROM PYTHON SOURCE LINES 31-79 .. code-block:: Python import matplotlib.pyplot as plt import nest import numpy as np nest.ResetKernel() nest.CopyModel("iaf_psc_alpha", "pyr") nest.CopyModel("iaf_psc_alpha", "in") pos = nest.spatial.grid(shape=[4, 3], extent=[2.0, 1.5]) ctx_pyr = nest.Create("pyr", positions=pos) ctx_in = nest.Create("in", positions=pos) nest.PrintNodes() # extract position information ppyr = nest.GetPosition(ctx_pyr) pin = nest.GetPosition(ctx_in) ppyr_x = np.array([x for x, y in ppyr]) ppyr_y = np.array([y for x, y in ppyr]) pin_x = np.array([x for x, y in pin]) pin_y = np.array([y for x, y in pin]) # plot plt.clf() plt.plot(pin_x - 0.05, ppyr_y - 0.05, "bo", markersize=20, label="Pyramidal", zorder=2) plt.plot(pin_x + 0.05, pin_y + 0.05, "ro", markersize=20, label="Interneuron", zorder=2) plt.plot( pin_x, ppyr_y, "o", markerfacecolor=(0.7, 0.7, 0.7), markersize=60, markeredgewidth=0, zorder=1, label="_nolegend_" ) # beautify plt.axis([-1.0, 1.0, -1.0, 1.0]) plt.axes().set_aspect("equal", "box") plt.axes().set_xticks((-0.75, -0.25, 0.25, 0.75)) plt.axes().set_yticks((-0.5, 0, 0.5)) plt.grid(True) plt.xlabel("4 Columns, Extent: 1.5") plt.ylabel("3 Rows, Extent: 1.0") plt.legend(numpoints=1) plt.show() # plt.savefig('ctx_2n.png') .. _sphx_glr_download_auto_examples_spatial_ctx_2n.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: ctx_2n.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: ctx_2n.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_