py4cytoscape.annotations.add_annotation_text

add_annotation_text(text=None, x_pos=None, y_pos=None, font_size=None, font_family=None, font_style=None, color=None, angle=None, name=None, canvas=None, z_order=None, network=None, base_url='http://127.0.0.1:1234/v1')[source]

Add Text Annotation

Adds a text annotation to a Cytoscape network view. The object will also be added to the Annotation Panel in the GUI.

Parameters
  • text (str) – The text to be displayed

  • x_pos (int) – X position in pixels from left; default is center of current view

  • y_pos (int) – Y position in pixels from top; default is center of current view

  • font_size (int) – Numeric value; default is 12

  • font_family (str) – Font family; default is Arial

  • font_style (str) – Font style; default is none

  • color (str) – hexadecimal color; default is #000000 (black)

  • angle (float) – Angle of text orientation; default is 0.0 (horizontal)

  • name (str) – Name of annotation object; default is “Text”

  • canvas (str) – Canvas to display annotation, i.e., foreground (default) or background

  • z_order (int) – Arrangement order specified by number (larger values are in front of smaller values); default is 0

  • network (SUID or str or None) – Name or SUID of the network. Default is the “current” network active in Cytoscape.

  • base_url (str) – Ignore unless you need to specify a custom domain, port or version to connect to the CyREST API. Default is http://localhost:1234 and the latest version of the CyREST API supported by this version of py4cytoscape.

Returns

A named list of annotation properties, including UUID

Return type

dict

Raises
  • CyError – if network name doesn’t exist or error in parameter value

  • requests.exceptions.HTTPError – if can’t connect to Cytoscape or Cytoscape returns an error

Examples

>>> add_annotation_text(text='ann1')
{'canvas': 'foreground', 'color': '#000000', 'rotation': '0.0', 'type': 'org.cytoscape.view.presentation.annotations.TextAnnotation', 'fontStyle': 'plain', 'uuid': '62748d4f-f412-423d-aa95-e269f0e4722c', 'fontFamily': 'Arial', 'name': 'Text', 'x': '2449.9784057344455', 'y': '1882.9888145962157', 'z': '0', 'fontSize': '12', 'text': 'ann1'}
>>> add_annotation_text(canvas='foreground', color='#000000', angle=41.0, font_style='plain', font_family='Arial', name='Text', x_pos=2168.2290309432974, y_pos=1823.4642987952689, z_order=0, font_size=14, text='Text')
{'canvas': 'foreground', 'color': '#000000', 'rotation': '41.0', 'type': 'org.cytoscape.view.presentation.annotations.TextAnnotation', 'fontStyle': 'plain', 'uuid': '293eeee1-b7e1-4d6b-bcf8-fd17fd2a2e5c', 'fontFamily': 'Arial', 'name': 'Text', 'x': '2168.2290309432974', 'y': '1823.4642987952689', 'z': '0', 'fontSize': '14', 'text': 'Text'}