diff --git a/src/py4vasp/_data/workfunction.py b/src/py4vasp/_data/workfunction.py index 326587ae..1c903d61 100644 --- a/src/py4vasp/_data/workfunction.py +++ b/src/py4vasp/_data/workfunction.py @@ -62,9 +62,7 @@ def to_graph(self): two lattice vectors is on the y axis. """ data = self.to_dict() - series = graph.Series( - data["distance"], data["average_potential"], data["direction"] - ) + series = graph.Series(data["distance"], data["average_potential"], "potential") return graph.Graph( - series=series, xlabel="distance (Å)", ylabel="average potential (eV)" + series=series, xlabel=f"distance along {data['direction']} (Å)", ylabel="average potential (eV)" ) diff --git a/tests/data/test_workfunction.py b/tests/data/test_workfunction.py index fcbcc6bf..fdc9f23c 100644 --- a/tests/data/test_workfunction.py +++ b/tests/data/test_workfunction.py @@ -38,11 +38,11 @@ def test_read(workfunction, Assert): def test_plot(workfunction, Assert): graph = workfunction.plot() - assert graph.xlabel == "distance (Å)" + assert graph.xlabel == f"distance along {workfunction.ref.lattice_vector} (Å)" assert graph.ylabel == "average potential (eV)" Assert.allclose(graph.series.x, workfunction.ref.distance) Assert.allclose(graph.series.y, workfunction.ref.average_potential) - assert graph.series.name == workfunction.ref.lattice_vector + assert graph.series.name == "potential" @patch("py4vasp._data.workfunction.Workfunction.to_graph")