.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/style/plot_ports.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_gallery_style_plot_ports.py: Edge ports ========== This example demonstrates how to use **ports**, which specify at which angle edges exit from and enter into vertices. Port directions are single or double letters borrowed from geography: `n` (north or up), `s` (south or down), `e` (east or right), `w` (west or left). `nw` (north-west) and similar directions are also allowed. Each edge has two ports, one for its exit from the source vertex, and one for its entry into the target vertex. For undirected graphs, these refer to the order in the graph data structure. If only one port is needed, you can set the other one to `None`. .. GENERATED FROM PYTHON SOURCE LINES 18-38 .. code-block:: Python import igraph as ig import matplotlib.pyplot as plt import iplotx as ipx g = ig.Graph.Ring(3, directed=True) ipx.network( g, layout="circle", edge_curved=True, edge_ports=[ ("n", "w"), # exit from the top, enter from the left ("e", "s"), # exit from the right, enter from the bottom ("n", "s"), # exit from the top, enter from the bottom ], edge_tension=[1.5, 1.8, 0.8], edge_color=["tomato", "steelblue", "purple"], ) .. image-sg:: /gallery/style/images/sphx_glr_plot_ports_001.png :alt: plot ports :srcset: /gallery/style/images/sphx_glr_plot_ports_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none [] .. GENERATED FROM PYTHON SOURCE LINES 39-41 Ports react to inversion of the x- or y-axis and set of axis limits from positive to negatives, e.g.: .. GENERATED FROM PYTHON SOURCE LINES 41-59 .. code-block:: Python fig, ax = plt.subplots() ipx.network( g, ax=ax, layout="circle", edge_curved=True, edge_ports=[ ("n", "w"), # exit from the top, enter from the left ("e", "s"), # exit from the right, enter from the bottom ("n", "s"), # exit from the top, enter from the bottom ], edge_tension=[1.5, 1.8, 0.8], edge_color=["tomato", "steelblue", "purple"], ) ax.invert_xaxis() ax.invert_yaxis() .. image-sg:: /gallery/style/images/sphx_glr_plot_ports_002.png :alt: plot ports :srcset: /gallery/style/images/sphx_glr_plot_ports_002.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 60-62 is the mirror image (in both x and y) of the previous plot. Here's the same example but setting some ports to None: .. GENERATED FROM PYTHON SOURCE LINES 62-76 .. code-block:: Python g = ig.Graph.Ring(3, directed=True) ipx.network( g, layout="circle", edge_curved=True, edge_ports=[ (None, "w"), ("e", "s"), ("n", None), ], edge_tension=[1.0, 1.8, 0.5], ) .. image-sg:: /gallery/style/images/sphx_glr_plot_ports_003.png :alt: plot ports :srcset: /gallery/style/images/sphx_glr_plot_ports_003.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none [] .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.087 seconds) .. _sphx_glr_download_gallery_style_plot_ports.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_ports.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_ports.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_ports.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_