Skip to content

Commit

Permalink
API: do not call matplotlib.pyplot.show inside plot_partition
Browse files Browse the repository at this point in the history
because it is implicit. The function `matplotlib.pyplot.show`
is to be called in user code, not within a package.
Moreover, this call raises a warning when the backend of
`matplotlib` is set to `'Agg'`, which is what happens in
one of `tulip`'s tests:

```
abstract_test.py::transition_directions_test
  .../lib/python3.9/site-packages/polytope/plot.py:133:
UserWarning: Matplotlib is currently using agg, which is a non-GUI
backend, so cannot show the figure.
    mpl.pyplot.show()
```
  • Loading branch information
johnyf committed Jun 8, 2021
1 parent beadd12 commit c464818
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions polytope/plot.py
Expand Up @@ -65,7 +65,7 @@ def plot_partition(
then transitions in C{ppp} are shown with arrows.
Otherwise C{ppp.adj} is plotted.
To show C{ppp.adj}, pass: trans = True
To plot C{ppp.adj}, pass: trans = True
@param plot_numbers: If True,
then annotate each Region center with its number.
Expand Down Expand Up @@ -118,7 +118,6 @@ def plot_partition(
reg.text(str(i), ax, color='black')
# not show trans ?
if trans is 'none':
mpl.pyplot.show()
return ax
# plot transition arrows between patches
rows, cols = np.nonzero(trans)
Expand All @@ -130,7 +129,6 @@ def plot_partition(

plot_transition_arrow(
ppp.regions[i], ppp.regions[j], ax, arr_size)
mpl.pyplot.show()
return ax


Expand Down

0 comments on commit c464818

Please sign in to comment.