.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/tree/plot_leafedges.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_tree_plot_leafedges.py: Leaf edges ========== This example shows how to use leaf edges, dashed lines connecting each leaf to the deepest leaf and label. .. GENERATED FROM PYTHON SOURCE LINES 8-21 .. code-block:: Python from ete4 import Tree import iplotx as ipx tree = Tree( "((),((),(((),()),((),()))));", ) ipx.plotting.tree( tree, leaf_labels={leaf: str(i + 1) for i, leaf in enumerate(tree.leaves())}, ) .. image-sg:: /gallery/tree/images/sphx_glr_plot_leafedges_001.png :alt: plot leafedges :srcset: /gallery/tree/images/sphx_glr_plot_leafedges_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 22-25 Leaf edges are used by default when leaf labels are present and deep leaves are set (default). If you use shallow leaves, leaf edges are not plotted: .. GENERATED FROM PYTHON SOURCE LINES 25-32 .. code-block:: Python ipx.plotting.tree( tree, leaf_labels={leaf: str(i + 1) for i, leaf in enumerate(tree.leaves())}, leaf_deep=False, ) .. image-sg:: /gallery/tree/images/sphx_glr_plot_leafedges_002.png :alt: plot leafedges :srcset: /gallery/tree/images/sphx_glr_plot_leafedges_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 33-34 Similarly, if there are no leaf labels, leaf edges are not plotted: .. GENERATED FROM PYTHON SOURCE LINES 34-39 .. code-block:: Python ipx.plotting.tree( tree, ) .. image-sg:: /gallery/tree/images/sphx_glr_plot_leafedges_003.png :alt: plot leafedges :srcset: /gallery/tree/images/sphx_glr_plot_leafedges_003.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 40-42 You can finely tune this behaviour. For instance, you can force leaf edges despite absence of leaf labels, and change their visual appearance: .. GENERATED FROM PYTHON SOURCE LINES 42-50 .. code-block:: Python ipx.plotting.tree( tree, leaf_deep=True, leafedge_color="tomato", leafedge_linewidth=2, leafedge_linestyle="-.", ) .. image-sg:: /gallery/tree/images/sphx_glr_plot_leafedges_004.png :alt: plot leafedges :srcset: /gallery/tree/images/sphx_glr_plot_leafedges_004.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.142 seconds) .. _sphx_glr_download_gallery_tree_plot_leafedges.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_leafedges.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_leafedges.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_leafedges.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_