Skip to content

Commit fda9ced

Browse files
authored
Adjust the way plot method uses MPL (#75)
* Add a description * default agg use for mpl * use agg adjust * use agg trigger adjust * udpate tests
1 parent ef31777 commit fda9ced

File tree

4 files changed

+16
-10
lines changed

4 files changed

+16
-10
lines changed

peartree/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '0.4.1'
1+
__version__ = '0.4.2'

peartree/paths.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,14 @@ def load_synthetic_network_as_graph(
168168
connection_threshold: float=50.0,
169169
walk_speed_kmph: float=4.5,
170170
impute_walk_transfers: bool=True):
171+
"""
172+
Convert a formatter transit FeatureCollection into a directed network graph.
173+
174+
Utilizing a correctly formatted transit FeatureCollection, generate a
175+
directed networ graph (or add to an existing one), based off of features
176+
included in the reference_geojson parameter.
177+
"""
178+
171179

172180
# Generate a random name for name if it is None
173181
if not name:

peartree/plot.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
import os
22

3-
import matplotlib
43
import networkx as nx
54
import osmnx as ox
65

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

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

15-
def generate_plot(G: nx.MultiDiGraph):
1614
# TODO: Build out custom plotting configurations but,
1715
# in the meantime, use OSMnx's plotting configurations
1816
# since they work well for the current use case and I

tests/test_plot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ def test_feed_to_graph_plot():
1717

1818
G = load_feed_as_graph(feed, start, end)
1919

20-
fig, ax = generate_plot(G)
20+
fig, ax = generate_plot(G, use_agg=True)

0 commit comments

Comments
 (0)