File: plot_tree-square.rst

package info (click to toggle)
python-cogent 2024.5.7a1%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 74,600 kB
  • sloc: python: 92,479; makefile: 117; sh: 16
file content (50 lines) | stat: -rw-r--r-- 1,168 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
.. jupyter-execute::
    :hide-code:

    import set_working_directory

Square Dendrogram Style
=======================

We use a tree saved in ``json`` format from a likelihood function analysis of a non-stationary model. The tree was derived such that the the branch lengths are now "ENS". 

.. note:: I change the scale bar placement. Valid values are ``"top left"``, ``"top right"``, ``"bottom left"`` (default), or ``"bottom right"``.

.. jupyter-execute::    

    from cogent3.app import io

    reader = io.load_json()

    ens_tree = reader("data/GN-tree.json")
    fig = ens_tree.get_figure(width=600, height=600)
    fig.scale_bar = "top right"
    fig.show()

.. jupyter-execute::
    :hide-code:

    outpath = set_working_directory.get_thumbnail_dir() / "plot_tree-square.png"

    fig.write(outpath)

Colouring a set of edges
------------------------

.. jupyter-execute::

    fig.style_edges(
        "AfricanEl",
        tip2="Manatee",
        legendgroup="Afrotheria",
        line=dict(color="magenta"),
    )
    fig.show()

With Contemporaneous Tips
-------------------------

.. jupyter-execute::

    fig.contemporaneous = True
    fig.show()