Skip to content

Commit 8966208

Browse files
committed
changes to avoid deprecation warnings in output_plots
1 parent 6214016 commit 8966208

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

ogcore/output_plots.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import numpy as np
22
import os
33
import matplotlib.pyplot as plt
4+
import matplotlib.ticker as mticker
45
from mpl_toolkits.mplot3d import Axes3D
56
import matplotlib
67
from ogcore.constants import (
@@ -391,7 +392,7 @@ def ss_3Dplot(
391392
data = (reform_ss[var] - base_ss[var]).T
392393
elif plot_type == "pct_diff":
393394
data = ((reform_ss[var] - base_ss[var]) / base_ss[var]).T
394-
cmap1 = matplotlib.cm.get_cmap("jet")
395+
cmap1 = matplotlib.colormaps.get_cmap("jet")
395396
X, Y = np.meshgrid(domain, Jgrid)
396397
fig5, ax5 = plt.subplots(subplot_kw={"projection": "3d"})
397398
ax5.set_xlabel(r"age-$s$")
@@ -652,7 +653,7 @@ def ability_bar_ss(
652653
plt.ylabel(r"Percentage Change in " + VAR_LABELS[var])
653654
if plot_title:
654655
plt.title(plot_title, fontsize=15)
655-
plt.legend(loc=9, bbox_to_anchor=(0.5, -0.15), ncol=2)
656+
# plt.legend(loc=9, bbox_to_anchor=(0.5, -0.15), ncol=2)
656657
if path:
657658
fig_path1 = os.path.join(path)
658659
plt.savefig(fig_path1, bbox_inches="tight", dpi=300)
@@ -1199,14 +1200,17 @@ def inequality_plot(
11991200
plt.title(plot_title, fontsize=15)
12001201
vals = ax1.get_yticks()
12011202
if plot_type == "pct_diff":
1202-
ax1.set_yticklabels(["{:,.2%}".format(x) for x in vals])
1203+
ticks_loc = ax1.get_yticks().tolist()
1204+
ax1.yaxis.set_major_locator(mticker.FixedLocator(ticks_loc))
1205+
ax1.set_yticklabels(["{:,.2%}".format(x) for x in ticks_loc])
12031206
plt.xlim(
12041207
(
12051208
base_params.start_year - 1,
12061209
base_params.start_year + num_years_to_plot,
12071210
)
12081211
)
1209-
plt.legend(loc=9, bbox_to_anchor=(0.5, -0.15), ncol=2)
1212+
if plot_type == "levels":
1213+
plt.legend(loc=9, bbox_to_anchor=(0.5, -0.15), ncol=2)
12101214
if path:
12111215
fig_path1 = os.path.join(path)
12121216
plt.savefig(fig_path1, bbox_inches="tight", dpi=300)

0 commit comments

Comments
 (0)