Skip to content

Commit 2f048cd

Browse files
committed
Fix PCP visualization not displaying plots #752
- Use plt.plot() instead of pymoo.visualization.util.plot() in PCP The util.plot() function expects 2D Pareto front arrays, not (x, y) line data - Remove forced Agg backend from matplotlib.py to allow interactive displays - Make backend check case-insensitive in plot.py (Agg vs agg)
1 parent 9b597cf commit 2f048cd

File tree

3 files changed

+4
-7
lines changed

3 files changed

+4
-7
lines changed

pymoo/core/plot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def show(self, **kwargs):
170170
self.plot_if_not_done_yet()
171171

172172
# in a notebook the plot method need not to be called explicitly
173-
if not in_notebook() and matplotlib.get_backend() != "agg":
173+
if not in_notebook() and matplotlib.get_backend().lower() != "agg":
174174
plt.show(**kwargs)
175175
plt.close()
176176

pymoo/visualization/matplotlib.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,7 @@
1515
from matplotlib import animation
1616
from matplotlib.collections import LineCollection, PatchCollection
1717
from matplotlib.colors import ListedColormap
18-
19-
# Set backend and configuration
20-
matplotlib.use('Agg', force=False) # Use non-interactive backend by default
21-
18+
2219
_MATPLOTLIB_AVAILABLE = True
2320

2421
# Export all commonly used matplotlib objects

pymoo/visualization/pcp.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import numpy as np
22

3-
import pymoo.visualization.util
43
from pymoo.docs import parse_doc_string
54
from pymoo.core.plot import Plot
65
from pymoo.util.misc import set_if_none, set_if_none_from_tuples
76
from pymoo.visualization.util import parse_bounds, normalize
7+
from pymoo.visualization.matplotlib import plt
88

99

1010
class PCP(Plot):
@@ -79,7 +79,7 @@ def _do(self):
7979
set_if_none(_kwargs, "color", self.colors[k % len(self.colors)])
8080

8181
for i in range(len(F)):
82-
pymoo.visualization.util.plot(np.arange(F.shape[1]), F[i, :], **_kwargs)
82+
plt.plot(np.arange(F.shape[1]), F[i, :], **_kwargs)
8383

8484
# Plot the parallel coordinate axes
8585
for i in range(self.n_dim):

0 commit comments

Comments
 (0)