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 json
|
||||
import matplotlib
|
||||
matplotlib.use('Agg') # don't show windows
|
||||
import matplotlib.pyplot as plt
|
||||
#import matplotlib
|
||||
#matplotlib.use('Agg') # don't show windows
|
||||
#import matplotlib.pyplot as plt
|
||||
import networkx as nx
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
from x import actions as xa
|
||||
from x import deployment as xd
|
||||
@@ -146,12 +147,17 @@ def init_cli_connections():
|
||||
@click.command()
|
||||
def graph():
|
||||
g = xs.connection_graph()
|
||||
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')
|
||||
|
||||
nx.write_dot(g, 'graph.dot')
|
||||
subprocess.call(['dot', '-Tps', 'graph.dot', '-o', 'graph.ps'])
|
||||
|
||||
# Matplotlib
|
||||
#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)
|
||||
|
||||
|
||||
3
main.yml
3
main.yml
@@ -16,7 +16,8 @@
|
||||
- shell: pip install -r /vagrant/requirements.txt
|
||||
|
||||
# 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
|
||||
#- shell: python setup.py develop chdir=/vagrant/solar
|
||||
|
||||
Reference in New Issue
Block a user