Skip to content

Commit 1d9469e

Browse files
committed
fix plt
1 parent 5612a98 commit 1d9469e

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

utils/plot.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
import sys
33
from typing import Dict, List, Union
44

5-
import matplotlib
65
from IPython.display import Image, display
76
from mat3ra.made.material import Material
87
from mat3ra.made.tools.analyze.interface import ZSLMatchHolder
98
from mat3ra.made.tools.analyze.rdf import RadialDistributionFunction
109
from mat3ra.utils.jupyterlite.plot import plot_distribution_function, scatter_plot_2d
10+
from matplotlib import pyplot as plt
1111

1212

1313
def plot_strain_vs_area(matches: List["ZSLMatchHolder"], settings: Dict[str, Union[str, int]]) -> None:
@@ -79,16 +79,14 @@ def plot_rdf(material: "Material", cutoff: float = 10.0, bin_size: float = 0.1)
7979
"""
8080
is_pyodide = sys.platform == "emscripten"
8181
if is_pyodide:
82-
matplotlib.use("Agg")
82+
plt.switch_backend("Agg")
8383

8484
rdf = RadialDistributionFunction.from_material(material, cutoff=cutoff, bin_size=bin_size)
8585
plot_distribution_function(
8686
rdf.bin_centers, rdf.rdf, xlabel="Distance (Å)", ylabel="g(r)", title="Radial Distribution Function (RDF)"
8787
)
8888

8989
if is_pyodide:
90-
import matplotlib.pyplot as plt
91-
9290
buf = io.BytesIO()
9391
plt.savefig(buf, format="png")
9492
buf.seek(0)

0 commit comments

Comments
 (0)