Skip to content

Commit

Permalink
Adjust the way plot method uses MPL (#75)
Browse files Browse the repository at this point in the history
* Add a description

* default agg use for mpl

* use agg adjust

* use agg trigger adjust

* udpate tests
  • Loading branch information
kuanb authored Jun 4, 2018
1 parent ef31777 commit fda9ced
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
2 changes: 1 addition & 1 deletion peartree/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.4.1'
__version__ = '0.4.2'
8 changes: 8 additions & 0 deletions peartree/paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,14 @@ def load_synthetic_network_as_graph(
connection_threshold: float=50.0,
walk_speed_kmph: float=4.5,
impute_walk_transfers: bool=True):
"""
Convert a formatter transit FeatureCollection into a directed network graph.
Utilizing a correctly formatted transit FeatureCollection, generate a
directed networ graph (or add to an existing one), based off of features
included in the reference_geojson parameter.
"""


# Generate a random name for name if it is None
if not name:
Expand Down
14 changes: 6 additions & 8 deletions peartree/plot.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
import os

import matplotlib
import networkx as nx
import osmnx as ox

# Check if the display has already been set and, if not...
cmd = 'python -c "import matplotlib.pyplot as plt;plt.figure()"'
check = os.system(cmd)
if check != 0:
# Force matplotlib to not use any Xwindows backend
matplotlib.use('Agg')

def generate_plot(G: nx.MultiDiGraph, use_agg=False):
# Load matplotlib only when plot requested
import matplotlib # noqa
if use_agg:
# Force matplotlib to not use any Xwindows backend
matplotlib.use('Agg')

def generate_plot(G: nx.MultiDiGraph):
# TODO: Build out custom plotting configurations but,
# in the meantime, use OSMnx's plotting configurations
# since they work well for the current use case and I
Expand Down
2 changes: 1 addition & 1 deletion tests/test_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ def test_feed_to_graph_plot():

G = load_feed_as_graph(feed, start, end)

fig, ax = generate_plot(G)
fig, ax = generate_plot(G, use_agg=True)

0 comments on commit fda9ced

Please sign in to comment.