Skip to content

Commit

Permalink
fix fig.xticks to ax migration in #3237
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielYang59 committed Aug 9, 2024
1 parent 54105bf commit a8d04f9
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 38 deletions.
85 changes: 48 additions & 37 deletions src/pymatgen/electronic_structure/plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2888,8 +2888,8 @@ def plot_seebeck_eff_mass_mu(self, temps=(300,), output="average", Lambda=0.5):

ax.set_xlabel("E-E$_f$ (eV)", fontsize=30)
ax.set_ylabel("Seebeck effective mass", fontsize=30)
ax.set_xticks(fontsize=25)
ax.set_yticks(fontsize=25)
ax.set_xticklabels(ax.get_xticklabels(), fontsize=25)
ax.set_yticklabels(ax.get_yticklabels(), fontsize=25)
if output == "tensor":
ax.legend(
[f"{dim}_{T}K" for T in temps for dim in ("x", "y", "z")],
Expand Down Expand Up @@ -2947,8 +2947,8 @@ def plot_complexity_factor_mu(self, temps=(300,), output="average", Lambda=0.5):

ax.set_xlabel("E-E$_f$ (eV)", fontsize=30)
ax.set_ylabel("Complexity Factor", fontsize=30)
ax.set_xticks(fontsize=25)
ax.set_yticks(fontsize=25)
ax.set_xticklabels(ax.get_xticklabels(), fontsize=25)
ax.set_yticklabels(ax.get_yticklabels(), fontsize=25)
if output == "tensor":
ax.legend(
[f"{dim}_{T}K" for T in temps for dim in ("x", "y", "z")],
Expand Down Expand Up @@ -2984,8 +2984,8 @@ def plot_seebeck_mu(self, temp: float = 600, output: str = "eig", xlim: Sequence
ax.set_xlim(xlim[0], xlim[1])
ax.set_ylabel("Seebeck \n coefficient ($\\mu$V/K)", fontsize=30.0)
ax.set_xlabel("E-E$_f$ (eV)", fontsize=30)
ax.set_xticks(fontsize=25)
ax.set_yticks(fontsize=25)
ax.set_xticklabels(ax.get_xticklabels(), fontsize=25)
ax.set_yticklabels(ax.get_yticklabels(), fontsize=25)
plt.tight_layout()
return ax

Expand Down Expand Up @@ -3022,8 +3022,8 @@ def plot_conductivity_mu(
ax.set_ylim([1e13 * relaxation_time, 1e20 * relaxation_time])
ax.set_ylabel("conductivity,\n $\\Sigma$ (1/($\\Omega$ m))", fontsize=30.0)
ax.set_xlabel("E-E$_f$ (eV)", fontsize=30.0)
ax.set_xticks(fontsize=25)
ax.set_yticks(fontsize=25)
ax.set_xticklabels(ax.get_xticklabels(), fontsize=25)
ax.set_yticklabels(ax.get_yticklabels(), fontsize=25)
plt.tight_layout()
return ax

Expand Down Expand Up @@ -3061,8 +3061,8 @@ def plot_power_factor_mu(
ax.set_xlim(xlim)
ax.set_ylabel("Power factor, ($\\mu$W/(mK$^2$))", fontsize=30.0)
ax.set_xlabel("E-E$_f$ (eV)", fontsize=30.0)
ax.set_xticks(fontsize=25)
ax.set_yticks(fontsize=25)
ax.set_xticklabels(ax.get_xticklabels(), fontsize=25)
ax.set_yticklabels(ax.get_yticklabels(), fontsize=25)
plt.tight_layout()
return ax

Expand Down Expand Up @@ -3098,8 +3098,8 @@ def plot_zt_mu(
ax.set_xlim(xlim)
ax.set_ylabel("ZT", fontsize=30.0)
ax.set_xlabel("E-E$_f$ (eV)", fontsize=30.0)
ax.set_xticks(fontsize=25)
ax.set_yticks(fontsize=25)
ax.set_xticklabels(ax.get_xticklabels(), fontsize=25)
ax.set_yticklabels(ax.get_yticklabels(), fontsize=25)
plt.tight_layout()
return ax

Expand Down Expand Up @@ -3145,15 +3145,18 @@ def plot_seebeck_temp(self, doping="all", output: Literal["average", "eigs"] = "

ax.legend(loc="best", fontsize=15)
ax.grid()
ax.set_xticks(fontsize=25)
ax.set_yticks(fontsize=25)
ax.set_xticklabels(ax.get_xticklabels(), fontsize=25)
ax.set_yticklabels(ax.get_yticklabels(), fontsize=25)

plt.tight_layout()

return ax

def plot_conductivity_temp(
self, doping="all", output: Literal["average", "eigs"] = "average", relaxation_time=1e-14
self,
doping="all",
output: Literal["average", "eigs"] = "average",
relaxation_time=1e-14,
):
"""Plot the conductivity in function of temperature for different doping levels.
Expand Down Expand Up @@ -3199,16 +3202,19 @@ def plot_conductivity_temp(

ax.legend(loc="best", fontsize=15)
ax.grid()
ax.set_xticks(fontsize=25)
ax.set_yticks(fontsize=25)
ax.set_xticklabels(ax.get_xticklabels(), fontsize=25)
ax.set_yticklabels(ax.get_yticklabels(), fontsize=25)
ax.ticklabel_format(style="sci", axis="y", scilimits=(0, 0))

plt.tight_layout()

return ax

def plot_power_factor_temp(
self, doping="all", output: Literal["average", "eigs"] = "average", relaxation_time=1e-14
self,
doping="all",
output: Literal["average", "eigs"] = "average",
relaxation_time=1e-14,
):
"""Plot the Power Factor in function of temperature for different doping levels.
Expand Down Expand Up @@ -3254,14 +3260,19 @@ def plot_power_factor_temp(

ax.legend(loc="best", fontsize=15)
ax.grid()
ax.set_xticks(fontsize=25)
ax.set_yticks(fontsize=25)
ax.set_xticklabels(ax.get_xticklabels(), fontsize=25)
ax.set_yticklabels(ax.get_yticklabels(), fontsize=25)
ax.ticklabel_format(style="sci", axis="y", scilimits=(0, 0))

plt.tight_layout()
return ax

def plot_zt_temp(self, doping="all", output: Literal["average", "eigs"] = "average", relaxation_time=1e-14):
def plot_zt_temp(
self,
doping="all",
output: Literal["average", "eigs"] = "average",
relaxation_time: float = 1e-14,
):
"""Plot the figure of merit zT in function of temperature for different doping levels.
Args:
Expand Down Expand Up @@ -3308,8 +3319,8 @@ def plot_zt_temp(self, doping="all", output: Literal["average", "eigs"] = "avera

ax.legend(loc="best", fontsize=15)
ax.grid()
ax.set_xticks(fontsize=25)
ax.set_yticks(fontsize=25)
ax.set_xticklabels(ax.get_xticklabels(), fontsize=25)
ax.set_yticklabels(ax.get_yticklabels(), fontsize=25)

plt.tight_layout()
return ax
Expand Down Expand Up @@ -3394,8 +3405,8 @@ def plot_seebeck_dop(self, temps="all", output: Literal["average", "eigs"] = "av
p = "lower right" if idx == 0 else "best"
ax.legend(loc=p, fontsize=15)
ax.grid()
ax.set_xticks(fontsize=25)
ax.set_yticks(fontsize=25)
ax.set_xticklabels(ax.get_xticklabels(), fontsize=25)
ax.set_yticklabels(ax.get_yticklabels(), fontsize=25)

plt.tight_layout()

Expand Down Expand Up @@ -3447,8 +3458,8 @@ def plot_conductivity_dop(self, temps="all", output: Literal["average", "eigs"]
ax.ticklabel_format(style="sci", axis="y", scilimits=(0, 0))
ax.legend(fontsize=15)
ax.grid()
ax.set_xticks(fontsize=25)
ax.set_yticks(fontsize=25)
ax.set_xticklabels(ax.get_xticklabels(), fontsize=25)
ax.set_yticklabels(ax.get_yticklabels(), fontsize=25)

plt.tight_layout()

Expand Down Expand Up @@ -3495,8 +3506,8 @@ def plot_power_factor_dop(self, temps="all", output: Literal["average", "eigs"]
p = "best" # 'lower right' if i == 0 else ''
ax.legend(loc=p, fontsize=15)
ax.grid()
ax.set_xticks(fontsize=25)
ax.set_yticks(fontsize=25)
ax.set_xticklabels(ax.get_xticklabels(), fontsize=25)
ax.set_yticklabels(ax.get_yticklabels(), fontsize=25)

plt.tight_layout()

Expand Down Expand Up @@ -3549,8 +3560,8 @@ def plot_zt_dop(self, temps="all", output: Literal["average", "eigs"] = "average
p = "lower right" if idx == 0 else "best"
ax.legend(loc=p, fontsize=15)
ax.grid()
ax.set_xticks(fontsize=25)
ax.set_yticks(fontsize=25)
ax.set_xticklabels(ax.get_xticklabels(), fontsize=25)
ax.set_yticklabels(ax.get_yticklabels(), fontsize=25)

plt.tight_layout()

Expand Down Expand Up @@ -3603,8 +3614,8 @@ def plot_eff_mass_dop(self, temps="all", output: Literal["average", "eigs"] = "a
p = "lower right" if idx == 0 else "best"
ax.legend(loc=p, fontsize=15)
ax.grid()
ax.set_xticks(fontsize=25)
ax.set_yticks(fontsize=25)
ax.set_xticklabels(ax.get_xticklabels(), fontsize=25)
ax.set_yticklabels(ax.get_yticklabels(), fontsize=25)

plt.tight_layout()

Expand Down Expand Up @@ -3641,8 +3652,8 @@ def plot_carriers(self, temp=300):
ax.set_ylim(1e14, 1e22)
ax.set_ylabel("carrier concentration (cm-3)", fontsize=30.0)
ax.set_xlabel("E-E$_f$ (eV)", fontsize=30)
ax.set_xticks(fontsize=25)
ax.set_yticks(fontsize=25)
ax.set_xticklabels(ax.get_xticklabels(), fontsize=25)
ax.set_yticklabels(ax.get_yticklabels(), fontsize=25)
plt.tight_layout()
return ax

Expand All @@ -3664,8 +3675,8 @@ def plot_hall_carriers(self, temp=300):
ax.set_ylim(1e14, 1e22)
ax.set_ylabel("Hall carrier concentration (cm-3)", fontsize=30.0)
ax.set_xlabel("E-E$_f$ (eV)", fontsize=30)
ax.set_xticks(fontsize=25)
ax.set_yticks(fontsize=25)
ax.set_xticklabels(ax.get_xticklabels(), fontsize=25)
ax.set_yticklabels(ax.get_yticklabels(), fontsize=25)
plt.tight_layout()
return ax

Expand Down
2 changes: 1 addition & 1 deletion tests/electronic_structure/test_plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ def test_fold_point(self):
@pytest.mark.skipif(not which("x_trans"), reason="No x_trans executable found")
class TestBoltztrapPlotter(TestCase):
def setUp(self):
bz = BoltztrapAnalyzer.from_files(f"{TEST_FILES_DIR}/boltztrap/transp/")
bz = BoltztrapAnalyzer.from_files(f"{TEST_FILES_DIR}/electronic_structure/boltztrap/transp/")
self.plotter = BoltztrapPlotter(bz)

def test_plot_carriers(self):
Expand Down

0 comments on commit a8d04f9

Please sign in to comment.