Skip to content

Commit 4609b51

Browse files
committed
fix arrow rendering, closes #10
1 parent bec2b4e commit 4609b51

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

src/ogdf_python/matplotlib/util.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
import warnings
2-
3-
import numpy as np
1+
import collections
2+
import itertools
43
import sys
4+
import warnings
55
from dataclasses import dataclass, asdict
66
from typing import List, Optional
7-
import collections
8-
import itertools
97

8+
import numpy as np
109
from matplotlib.collections import PathCollection, Collection
1110
from matplotlib.figure import Figure
1211
from matplotlib.path import Path
@@ -300,12 +299,14 @@ def get_edge_path(GA, edge, label_pos=ogdf.DPoint(), closed=False, curviness=0):
300299
path.append(np.array(tgt_arr_path))
301300
codes.append(np.full(len(tgt_arr_path), Path.LINETO))
302301

303-
codes[0][0] = Path.MOVETO
304302
if closed:
305303
path.append(edge_path[::-1])
306304
codes.append(edge_codes)
307305

308-
return Path(np.concatenate(path), np.concatenate(codes))
306+
path_flat = np.concatenate(path)
307+
codes_flat = np.concatenate(codes)
308+
codes_flat[0] = Path.MOVETO
309+
return Path(path_flat, codes_flat)
309310

310311

311312
def find_closest(GA, x, y, edge_dist=10):
@@ -330,8 +331,8 @@ def new_figure(*args, **kwargs) -> Figure:
330331
""" Create a new figure without changing the currently active figure of pyplot """
331332
import matplotlib.pyplot as plt
332333
from matplotlib import _pylab_helpers
333-
plt._get_backend_mod() # make sure backend is loaded before ioff call
334-
with plt.ioff(): # disable immediate display of created figures
334+
plt._get_backend_mod() # make sure backend is loaded before ioff call
335+
with plt.ioff(): # disable immediate display of created figures
335336
old_fig = None
336337
# like plt.gcf(), but does not create one if none is active
337338
manager = _pylab_helpers.Gcf.get_active()
@@ -341,5 +342,5 @@ def new_figure(*args, **kwargs) -> Figure:
341342
fig = plt.figure(*args, **kwargs)
342343

343344
if old_fig is not None:
344-
plt.figure(old_fig) # reactivate the old figure
345+
plt.figure(old_fig) # reactivate the old figure
345346
return fig

0 commit comments

Comments
 (0)