✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
🧬 Learn how to build RNA-Seq data apps with Python & Dash. Register for the May 20 Webinar!

How to add anotations for each subplot?

Hi!

I have a dashboard with several subplots.

I would like to add annotations (e.g. arrow with the max value) for each subplot. How can I do this?

add_annotation doesn’t have a row and column to specify for which subplot the annotation should be used.

Cheers!

Hi @NielsHoogeveen,

To add annotations to each subplot, insert

print_grid=True
in fig = make_subplots() to see the axes name assigned to each subplot.

Then to add an annotation to the subplot referenced with respect to ‘x2’, ‘y2’, specify the corresponding axes as follows:

xref ='x2',
yref ='y2'

See help(go.layout.Annotation.xref):

Help on property:

    Sets the annotation's x coordinate axis. If set to an x axis id
    (e.g. "x" or "x2"), the `x` position refers to an x coordinate
    If set to "paper", the `x` position refers to the distance from
    the left side of the plotting area in normalized coordinates
    where 0 (1) corresponds to the left (right) side.
    
    The 'xref' property is an enumeration that may be specified as:
      - One of the following enumeration values:
            ['paper']
      - A string that matches one of the following regular expressions:
            ['^x([2-9]|[1-9][0-9]+)?$']
    
    Returns
    -------
    Any