Skip to content

Plotting doesn't work on a clean install #38

@LukeWeidenwalker

Description

@LukeWeidenwalker

Currently, plotting doesn't work out of the box for two reasons:

  1. igraph requires the pycairo or cairocffi libraries to be installed, these are not specified in setup.cfg
  2. Upon installing cairocffi, calling parsed_pg.plot() results in the exception quoted further below. Process graph also below.

I've been able to circumvent this problem quite easily by using the networkx library instead.
Happy to raise a PR if we're okay with replacing igraph.

@clausmichele I don't know who uses this library / who is responsible for it these days, could you please tag any folks you think should have a say in this? Much appreciated :)


---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
File /opt/conda/lib/python3.9/site-packages/IPython/core/formatters.py:343, in BaseFormatter.__call__(self, obj)
    341     method = get_real_method(obj, self.print_method)
    342     if method is not None:
--> 343         return method()
    344     return None
    345 else:

File /opt/conda/lib/python3.9/site-packages/igraph/drawing/__init__.py:367, in Plot._repr_svg_(self)
    365 context = cairo.Context(surface)
    366 # Plot the graph on this context
--> 367 self.redraw(context)
    368 # No idea why this is needed but python crashes without
    369 context.show_page()

File /opt/conda/lib/python3.9/site-packages/igraph/drawing/__init__.py:276, in Plot.redraw(self, context)
    274 else:
    275     ctx.save()
--> 276 plotter(ctx, bbox, palette, *args, **kwds)
    277 if opacity < 1.0:
    278     ctx.pop_group_to_source()

File /opt/conda/lib/python3.9/site-packages/igraph/__init__.py:4166, in Graph.__plot__(self, context, bbox, palette, *args, **kwds)
   4164     del kwds["drawer_factory"]
   4165 drawer = drawer_factory(context, bbox)
-> 4166 drawer.draw(self, palette, *args, **kwds)

File /opt/conda/lib/python3.9/site-packages/igraph/drawing/graph.py:489, in DefaultGraphDrawer.draw(self, graph, palette, *args, **kwds)
    487 src, dest = edge.tuple
    488 src_vertex, dest_vertex = vertex_builder[src], vertex_builder[dest]
--> 489 (x, y), (halign, valign) = edge_drawer.get_label_position(
    490     edge, src_vertex, dest_vertex
    491 )
    493 # Measure the text
    494 _, yb, w, h, _, _ = label_drawer.text_extents()

File /opt/conda/lib/python3.9/site-packages/igraph/drawing/edge.py:159, in AbstractEdgeDrawer.get_label_position(self, edge, src_vertex, dest_vertex)
    155     angle = None
    158 # Determine the midpoint
--> 159 if edge.curved:
    160     (x1, y1), (x2, y2) = src_vertex.position, dest_vertex.position
    161     aux1, aux2 = get_bezier_control_points_for_curved_edge(x1, y1, x2, y2, edge.curved)

AttributeError: 'igraph.Edge' object has no attribute 'curved'

This occurred on the following process graph I was experimenting with:

{'process_graph': {'loadcollection1': {'process_id': 'load_collection',
   'arguments': {'bands': ['B02', 'B03', 'B04', 'B08'],
    'id': 'boa_sentinel_2',
    'spatial_extent': {'east': 9.992539570642537,
     'north': 47.73255902176489,
     'south': 46.82379186182021,
     'west': 8.259091264204697},
    'temporal_extent': ['2018-05-01', '2018-09-01']}},
  'reducedimension1': {'process_id': 'reduce_dimension',
   'arguments': {'data': {'from_node': 'loadcollection1'},
    'dimension': 't',
    'reducer': {'process_graph': {'median1': {'process_id': 'median',
       'arguments': {'data': {'from_parameter': 'data'}},
       'result': True}}}}},
  'loadvectorcube1': {'process_id': 'load_vector_cube',
   'arguments': {'URL': 'https://raw.githubusercontent.com/LukeWeidenwalker/SRR3_clustered_geojsons/master/AOI_clustered_distance_2/cluster_3.geojson'}},
  'aggregatespatial1': {'process_id': 'aggregate_spatial',
   'arguments': {'data': {'from_node': 'reducedimension1'},
    'geometries': {'from_node': 'loadvectorcube1'},
    'reducer': 'mean',
    'target_dimension': 'result'}},
  'fitregrrandomforest1': {'process_id': 'fit_regr_random_forest',
   'arguments': {'data': {'from_node': 'aggregatespatial1'},
    'max_variables': None,
    'num_trees': 100,
    'predictors_vars': ['B02', 'B03', 'B04', 'B08'],
    'seed': 0,
    'target_var': 'target_canopy_cover'}},
  'savemlmodel1': {'process_id': 'save_ml_model',
   'arguments': {'model': {'from_node': 'fitregrrandomforest1'}},
   'result': True}}}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions