Skip to content

Commit eb0b516

Browse files
committed
[plotting] remove matplotlib as global dependency
1 parent 97c9f3c commit eb0b516

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

comocma/como_logger.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"""Defines the `COMOPlot` class which can store (via callback) and plot data.
22
"""
33
import numpy as np
4-
import matplotlib.pyplot as plt
54
import os
65
import datetime
76
from time import time
@@ -343,6 +342,7 @@ def plot(self):
343342

344343
def plot_proportion_dominated_final_incumbents(self):
345344
"""Plot the proportion of dominated final incumbents."""
345+
import matplotlib.pyplot as plt
346346
dic = self.load()
347347
try:
348348
n_runs = len(dic["completed_runs"])
@@ -362,6 +362,7 @@ def plot_iterations_per_restart(self):
362362
"""
363363
Plot the number of iterations per restart and the condition number.
364364
"""
365+
import matplotlib.pyplot as plt
365366
dic = self.load()
366367
try:
367368
n_runs = len(dic["completed_runs"])
@@ -390,6 +391,7 @@ def plot_iterations_per_restart(self):
390391

391392
def plot_convergence_speed(self):
392393
"""Plot the convergence speed."""
394+
import matplotlib.pyplot as plt
393395
dic = self.load()
394396
if self.offset is None:
395397
offset = dic["hv_archive"][-1]
@@ -409,6 +411,7 @@ def plot_convergence_speed(self):
409411

410412
def plot_archive(self):
411413
"""Plot the archive."""
414+
import matplotlib.pyplot as plt
412415
dic = self.load()
413416
non_dominated_kernels = [v for v in dic["objective_values"][-1]
414417
if v in dic["last_archive"]]
@@ -436,6 +439,7 @@ def plot_archive(self):
436439

437440
def plot_hvi(self):
438441
"""Plot information regarding hypervolume improvement."""
442+
import matplotlib.pyplot as plt
439443
dic = self.load()
440444
try:
441445
n_runs = len(dic["completed_runs"])
@@ -480,6 +484,7 @@ def plot_stepsizes(self):
480484
Plot the first, the last, the minimum and the maximum stepsizes of all completed runs, plus
481485
the initial stepsize of the last run.
482486
"""
487+
import matplotlib.pyplot as plt
483488
dic = self.load()
484489

485490
try:
@@ -511,6 +516,7 @@ def plot_uhvi(self):
511516
* correct the bug where there is only one tick if the span is too little, making the plot
512517
unreadable
513518
"""
519+
import matplotlib.pyplot as plt
514520
dic = self.load()
515521

516522
try:

0 commit comments

Comments
 (0)