File: plot_tree-support.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 (40 lines) | stat: -rw-r--r-- 1,395 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
.. jupyter-execute::
    :hide-code:

    import set_working_directory

Showing Bootstrap Support
=========================

We use a tree saved in ``json`` format from a 100 replicate bootstrap resamplings. The ``show_support=True`` argument controls whether or not to display support. The ``threshold=0.8`` argument indicates only nodes with a support level ≤0.8 will have support text displayed.

.. jupyter-execute::

    from cogent3.app import io

    reader = io.load_json()

    tree = reader("data/tree-with-support.json")
    fig = tree.get_figure(show_support=True, threshold=0.8)
    fig.scale_bar = None
    fig.show(width=500, height=400)

Change the placement of support text
------------------------------------

The support text is positioned relative to the ``x``, ``y`` coordinates of the tree node. Control over support text placement is achieved using the ``support_xshift`` and ``support_yshift`` attributes. These are expressed in terms of pixels.

To place the support text internal to the node, we set the ``yshift=0`` (so at the same y-value of the node) and xshift it to the right using a positive integer.

.. jupyter-execute::

    fig.support_xshift = 15
    fig.support_yshift = 0
    fig.show(width=500, height=400)

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

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

    fig.write(outpath)