.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/tree/plot_cogent3_layouts.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_cogent3_layouts.py: Cogent3 layouts =============== This example shows how to reproduce `cogent3` layouts using `iplotx`. .. note:: `cogent3` uses `plotly` as their default backend, whereas `iplotx` uses `matplotlib`. Each backend has pros and cons. In general, `plotly` is more directed towards web visualisation thanks to their JavaScript library, whereas `matplotlib` is probably more popular and supported outside of web environments. .. GENERATED FROM PYTHON SOURCE LINES 13-29 .. 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=(5, 4)) art = ipx.tree( tree, ax=ax, leaf_labels=True, style="cogent3", ) .. image-sg:: /gallery/tree/images/sphx_glr_plot_cogent3_layouts_001.png :alt: plot cogent3 layouts :srcset: /gallery/tree/images/sphx_glr_plot_cogent3_layouts_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 30-31 Angular layouts (without waypoints, looks more pointy) are supported: .. GENERATED FROM PYTHON SOURCE LINES 31-42 .. code-block:: Python fig, ax = plt.subplots(figsize=(5, 4)) art = ipx.tree( tree, layout="horizontal", ax=ax, leaf_labels=True, layout_angular=True, style="cogent3", ) .. image-sg:: /gallery/tree/images/sphx_glr_plot_cogent3_layouts_002.png :alt: plot cogent3 layouts :srcset: /gallery/tree/images/sphx_glr_plot_cogent3_layouts_002.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 43-44 Vertical and radial layouts are also supported along the same lines: .. GENERATED FROM PYTHON SOURCE LINES 44-58 .. code-block:: Python fig, axs = plt.subplots(3, 1, figsize=(6, 15)) for ax, layout in zip(axs, ("vertical", "radial", "horizontal")): art = ipx.tree( tree, layout=layout, layout_orientation="left" if layout == "horizontal" else None, ax=ax, leaf_labels=True, layout_angular=True, style="cogent3", ) fig.tight_layout() .. image-sg:: /gallery/tree/images/sphx_glr_plot_cogent3_layouts_003.png :alt: plot cogent3 layouts :srcset: /gallery/tree/images/sphx_glr_plot_cogent3_layouts_003.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 59-60 Nonangular trees can be used too: .. GENERATED FROM PYTHON SOURCE LINES 60-73 .. code-block:: Python fig, axs = plt.subplots(3, 1, figsize=(6, 15)) for ax, layout in zip(axs, ("vertical", "radial", "horizontal")): art = ipx.tree( tree, layout=layout, layout_orientation="left" if layout == "horizontal" else None, ax=ax, leaf_labels=True, layout_angular=False, style="cogent3", ) fig.tight_layout() .. image-sg:: /gallery/tree/images/sphx_glr_plot_cogent3_layouts_004.png :alt: plot cogent3 layouts :srcset: /gallery/tree/images/sphx_glr_plot_cogent3_layouts_004.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.712 seconds) .. _sphx_glr_download_gallery_tree_plot_cogent3_layouts.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_cogent3_layouts.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_cogent3_layouts.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_cogent3_layouts.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_