py4cytoscape.annotations.add_annotation_image

add_annotation_image(url=None, x_pos=None, y_pos=None, angle=None, opacity=None, brightness=None, contrast=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 Image Annotation

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

Parameters
  • url (str) – URL or path to image file. File paths can be absolute or relative to current working directory or sandbox. URLs must start with http:// or https://.

  • 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)

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

  • brightness (int) – Image brightness. Must be an integer between -100 and 100; default is 0.

  • contrast (int) – Image contrast. Must be an integer between -100 and 100; default is 0.

  • 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_image(url='https://www.ucsd.edu/_resources/img/logo_UCSD.png')
{'edgeThickness': '1.0', 'canvas': 'foreground', 'rotation': '0.0', 'type': 'org.cytoscape.view.presentation.annotations.ImageAnnotation', 'uuid': '683b7c67-dcb3-459f-9505-b8ec05f3c76f', 'URL': 'https://www.ucsd.edu/_resources/img/logo_UCSD.png', 'shapeType': 'RECTANGLE', 'edgeColor': '#000000', 'brightness': '0', 'edgeOpacity': '100.0', 'contrast': '0', 'name': 'Image 1', 'x': '2449.9784057344455', 'width': '500.0', 'y': '1882.9888145962157', 'z': '0', 'opacity': '1.0', 'height': '100.0'}
>>> add_annotation_image(url='https://www.ucsd.edu/_resources/img/logo_UCSD.png', x_pos=100, y_pos=200, angle=45, opacity=50, brightness=60, contrast=70, border_thickness=2, border_color='#0F0F0F', border_opacity=75, height=30, width=31, name='ann3 name', canvas='background')
{'edgeThickness': '2.0', 'canvas': 'background', 'rotation': '45.0', 'type': 'org.cytoscape.view.presentation.annotations.ImageAnnotation', 'uuid': 'a67674cf-f787-4b7c-bae5-3a6b00a2f00c', 'URL': 'https://www.ucsd.edu/_resources/img/logo_UCSD.png', 'shapeType': 'RECTANGLE', 'edgeColor': '#0F0F0F', 'brightness': '60', 'edgeOpacity': '75.0', 'contrast': '70', 'name': 'ann3 name', 'x': '100.0', 'width': '31.0', 'y': '200.0', 'z': '0', 'opacity': '0.5', 'height': '30.0'}