.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/tree/plot_tree_style_clades.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_tree_style_clades.py: Subtree styling =============== This example shows how to style tree clades - or subtrees - post rendering, similar of the equivalent option in `cogent3`. .. GENERATED FROM PYTHON SOURCE LINES 8-38 .. code-block:: Python import cogent3 import matplotlib.pyplot as plt import iplotx as ipx tree = cogent3.load_tree("data/tree-with-support.json") fig, ax = plt.subplots(figsize=(8, 8)) art = ipx.tree( tree, layout="radial", ax=ax, leaf_labels=True, layout_angular=True, leaf_deep=False, margin=0.1, ) # Style the subtree spanned by the first two leaves # with red edges. art.style_subtree( tree.tips()[:2], { "edge": { "color": "red", }, }, ) .. image-sg:: /gallery/tree/images/sphx_glr_plot_tree_style_clades_001.png :alt: plot tree style clades :srcset: /gallery/tree/images/sphx_glr_plot_tree_style_clades_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 39-40 The same can be done with nonangular layouts: .. GENERATED FROM PYTHON SOURCE LINES 40-59 .. code-block:: Python fig, ax = plt.subplots(figsize=(8, 8)) art = ipx.tree( tree, layout="horizontal", ax=ax, leaf_labels=True, layout_angular=False, leaf_deep=False, margin=0.1, ) art.style_subtree( tree.tips()[:2], { "edge": { "color": "red", }, }, ) .. image-sg:: /gallery/tree/images/sphx_glr_plot_tree_style_clades_002.png :alt: plot tree style clades :srcset: /gallery/tree/images/sphx_glr_plot_tree_style_clades_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.179 seconds) .. _sphx_glr_download_gallery_tree_plot_tree_style_clades.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_tree_style_clades.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_tree_style_clades.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_tree_style_clades.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_