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
  • #516
Closed
Open
Issue created Nov 21, 2018 by William Weir@wweir827

multiaxes layouts not working

I'm trying to layout multiple graphs in the same matplotlib figure using graph_tool.draw.graph_draw on different axes.

I'm using

Python Version: Python 2.7.15 graph_tool version: 2.26 (commit b89e6b4e, Thu Nov 9 14:55:43 2017 +0000) matplotlib version: 2.2.2

Here is an example of what I would like to do:

import matplotlib.pyplot as plt
import matplotlib.patches as patches
import graph_tool.draw as gtd
import graph_tool.generation as gtg
import graph_tool.stats as gtstats
import numpy as np

plt.switch_backend('cairo')

plt.close()
f=plt.gcf()
f.set_size_inches((10,10))
rbc=(9,9)
#set up axes
a0=plt.subplot2grid(rbc,(6,0),rowspan=3,colspan=3)
a1=plt.subplot2grid(rbc,(6,3),colspan=3,rowspan=3)
a2=plt.subplot2grid(rbc,(6,6),rowspan=3,colspan=3)

b=np.random.choice([0,1],size=40)
probs=np.array([[100,10],[10,100]])


g1=gtg.generate_sbm(b=b,probs=probs)
pos1 = gtd.sfdp_layout(g1)

g2=gtg.generate_sbm(b=b,probs=probs)
pos2 = gtd.sfdp_layout(g2)

g3=gtg.generate_sbm(b=b,probs=probs)
pos3 = gtd.sfdp_layout(g3)

gtd.graph_draw(g1,inline=False,pos=pos1,
               vertex_fill_color='blue',mplfig=a0)

gtd.graph_draw(g2,inline=False,pos=pos2,
               vertex_fill_color='red',mplfig=a1)

gtd.graph_draw(g3,inline=False,pos=pos3,
               vertex_fill_color='green',mplfig=a2)

#for reference
a0.add_patch(patches.Rectangle(xy=(.1,.1),width=.9,height=.9,edgecolor='b',facecolor='none',transform=a0.transAxes))
a1.add_patch(patches.Rectangle(xy=(.1,.1),width=.9,height=.9,edgecolor='r',facecolor='none',transform=a1.transAxes))
a2.add_patch(patches.Rectangle(xy=(.1, .1), width=.9, height=.9, edgecolor='g', facecolor='none', transform=a2.transAxes))

f.savefig('test.pdf')

test.pdf

Edited Nov 21, 2018 by Tiago Peixoto
Assignee
Assign to
Time tracking