Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • graph-tool graph-tool
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 48
    • Issues 48
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar

Please use the issue tracker only to report bugs (i.e. errors in the library that need to be fixed) or feature requests.

For questions about how to compile, install or use the library, please use instead the web forum at https://forum.skewed.de/c/graph-tool.


(If unsure, use the forum first.)


IMPORTANT: When opening new issues, please choose the BUG template from the drop-down menu, and fill out the required information.

  • Tiago Peixoto
  • graph-toolgraph-tool
  • Issues
  • #418
Closed
Open
Issue created Oct 03, 2017 by Snehal Shekatkar@snehalshekatkar

graph_draw with subplots

I am trying to plot different graphs using plt.subplots. Following code throws an error:

import graph_tool.all as gt
import matplotlib.pyplot as plt
plt.switch_backend('cairo')

g1 = gt.collection.data['karate']
g2 = gt.collection.data['dolphins']

ax = plt.subplot(1, 2, 1)
gt.graph_draw(g1, mplfig = ax)
ax = plt.subplot(1, 2, 2)
gt.graph_draw(g2, mplfig = ax)
ax = plt.subplot(2, 2, 3)

plt.savefig('test.pdf')

The error is given below:

Traceback (most recent call last):
  File "test.py", line 20, in <module>
    plt.savefig('abc.pdf')
  File "/usr/lib/python3/dist-packages/matplotlib/pyplot.py", line 688, in savefig
    res = fig.savefig(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/matplotlib/figure.py", line 1565, in savefig
    self.canvas.print_figure(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/matplotlib/backend_bases.py", line 2232, in print_figure
    **kwargs)
  File "/usr/lib/python3/dist-packages/matplotlib/backends/backend_cairo.py", line 448, in print_pdf
    return self._save(fobj, 'pdf', *args, **kwargs)
  File "/usr/lib/python3/dist-packages/matplotlib/backends/backend_cairo.py", line 512, in _save
    self.figure.draw (renderer)
  File "/usr/lib/python3/dist-packages/matplotlib/artist.py", line 61, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/matplotlib/figure.py", line 1159, in draw
    func(*args)
  File "/usr/lib/python3/dist-packages/matplotlib/artist.py", line 61, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/matplotlib/axes/_base.py", line 2324, in draw
    a.draw(renderer)
  File "/usr/lib/python3/dist-packages/graph_tool/draw/cairo_draw.py", line 1570, in draw
    self.vorder, self.eorder, self.nodesfirst, self.kwargs)
  File "/usr/lib/python3/dist-packages/graph_tool/draw/cairo_draw.py", line 692, in cairo_draw
    vdefs = _attrs(_vdefaults, "v", g, vcmap)[1]
  File "/usr/lib/python3/dist-packages/graph_tool/draw/cairo_draw.py", line 486, in _attrs
    defaults[int(attr)] = _convert(attr, v, cmap)
  File "/usr/lib/python3/dist-packages/graph_tool/draw/cairo_draw.py", line 323, in _convert
    cmap, alpha = cmap
ValueError: not enough values to unpack (expected 2, got 0)
Assignee
Assign to
Time tracking