Use graphviz to render graph instead of matplotlib
It looks better
This commit is contained in:
24
cli.py
24
cli.py
@@ -1,10 +1,11 @@
|
|||||||
import click
|
import click
|
||||||
import json
|
import json
|
||||||
import matplotlib
|
#import matplotlib
|
||||||
matplotlib.use('Agg') # don't show windows
|
#matplotlib.use('Agg') # don't show windows
|
||||||
import matplotlib.pyplot as plt
|
#import matplotlib.pyplot as plt
|
||||||
import networkx as nx
|
import networkx as nx
|
||||||
import os
|
import os
|
||||||
|
import subprocess
|
||||||
|
|
||||||
from x import actions as xa
|
from x import actions as xa
|
||||||
from x import deployment as xd
|
from x import deployment as xd
|
||||||
@@ -146,12 +147,17 @@ def init_cli_connections():
|
|||||||
@click.command()
|
@click.command()
|
||||||
def graph():
|
def graph():
|
||||||
g = xs.connection_graph()
|
g = xs.connection_graph()
|
||||||
pos = nx.spring_layout(g)
|
|
||||||
nx.draw_networkx_nodes(g, pos)
|
nx.write_dot(g, 'graph.dot')
|
||||||
nx.draw_networkx_edges(g, pos, arrows=True)
|
subprocess.call(['dot', '-Tps', 'graph.dot', '-o', 'graph.ps'])
|
||||||
nx.draw_networkx_labels(g, pos)
|
|
||||||
plt.axis('off')
|
# Matplotlib
|
||||||
plt.savefig('graph.png')
|
#pos = nx.spring_layout(g)
|
||||||
|
#nx.draw_networkx_nodes(g, pos)
|
||||||
|
#nx.draw_networkx_edges(g, pos, arrows=True)
|
||||||
|
#nx.draw_networkx_labels(g, pos)
|
||||||
|
#plt.axis('off')
|
||||||
|
#plt.savefig('graph.png')
|
||||||
|
|
||||||
connections.add_command(graph)
|
connections.add_command(graph)
|
||||||
|
|
||||||
|
|||||||
3
main.yml
3
main.yml
@@ -16,7 +16,8 @@
|
|||||||
- shell: pip install -r /vagrant/requirements.txt
|
- shell: pip install -r /vagrant/requirements.txt
|
||||||
|
|
||||||
# Graph drawing
|
# Graph drawing
|
||||||
- apt: name=python-matplotlib state=present
|
#- apt: name=python-matplotlib state=present
|
||||||
|
- apt: name=python-graphviz state=present
|
||||||
|
|
||||||
# Setup development env for solar
|
# Setup development env for solar
|
||||||
#- shell: python setup.py develop chdir=/vagrant/solar
|
#- shell: python setup.py develop chdir=/vagrant/solar
|
||||||
|
|||||||
Reference in New Issue
Block a user