py4cytoscape.annotations.add_annotation_shape

add_annotation_shape(type=None, custom_shape=None, x_pos=None, y_pos=None, angle=None, fill_color=None, opacity=None, border_thickness=None, border_color=None, border_opacity=None, height=None, width=None, name=None, canvas=None, z_order=None, network=None, base_url='http://127.0.0.1:1234/v1')[source]

Add Shape Annotation

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

Parameters
  • type (str) – The type of the shape, default is RECTANGLE. See get_node_shapes() for valid options.

  • custom_shape (str) – If a custom shape, this is the text of the shape

  • 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

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

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

  • opacity (int) – Opacity of fill color. Must be an integer between 0 and 100; default is 100

  • border_thickness (int) – non-negative integer

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

  • border_opacity (int) – Integer between 0 and 100; default is 100

  • height (int) – Height of bounding shape; default is based on text height

  • width (int) –

  • 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_shape()
{'edgeThickness': '1.0', 'canvas': 'foreground', 'fillOpacity': '100.0', 'rotation': '0.0', 'type': 'org.cytoscape.view.presentation.annotations.ShapeAnnotation', 'uuid': '4e189482-6acb-472b-8077-683a548361b2', 'shapeType': 'RECTANGLE', 'edgeColor': '#000000', 'edgeOpacity': '100.0', 'name': 'Shape 1', 'x': '2449.9784057344455', 'width': '100.0', 'y': '1882.9888145962157', 'z': '0', 'height': '100.0'}
>>> add_annotation_shape(type='ELLIPSE', custom_shape=None, x_pos=100, y_pos=200, angle=45, fill_color='#F0F0F0', opacity=50, border_thickness=2, border_color='#0F0F0F', border_opacity=75, height=30, width=31, name='ann3 name', canvas='background')
{'edgeThickness': '2.0', 'canvas': 'background', 'fillOpacity': '50.0', 'rotation': '45.0', 'type': 'org.cytoscape.view.presentation.annotations.ShapeAnnotation', 'uuid': '5a590eec-5281-44d2-9e51-1a4476381cf1', 'fillColor': '#F0F0F0', 'shapeType': 'ELLIPSE', 'edgeColor': '#0F0F0F', 'edgeOpacity': '75.0', 'name': 'ann3 name', 'x': '100.0', 'width': '31.0', 'y': '200.0', 'z': '0', 'height': '30.0'}