Skip to content

Commit 19c90fc

Browse files
authored
Merge pull request PSLmodels#952 from jdebacker/demog_plots
Merging
2 parents d76096f + 410af1c commit 19c90fc

File tree

5 files changed

+35
-21
lines changed

5 files changed

+35
-21
lines changed

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.11.14] - 2024-07-30 12:00:00
9+
10+
### Added
11+
12+
- Aesthetic updates to plotting functions in `parameter_plots.py` and `demographics.py`
13+
814
## [0.11.13] - 2024-07-28 12:00:00
915

1016
### Added
@@ -270,7 +276,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
270276
- Version [0.7.0] on August 30, 2021 was the first time that the OG-USA repository was detached from all of the core model logic, which was named OG-Core. Before this version, OG-USA was part of what is now the [`OG-Core`](https://github.com/PSLmodels/OG-Core) repository. In the next version of OG-USA, we adjusted the version numbering to begin with 0.1.0. This initial version of 0.7.0, was sequential from what OG-USA used to be when the OG-Core project was called OG-USA.
271277
- Any earlier versions of OG-USA can be found in the [`OG-Core`](https://github.com/PSLmodels/OG-Core) repository [release history](https://github.com/PSLmodels/OG-Core/releases) from [v.0.6.4](https://github.com/PSLmodels/OG-Core/releases/tag/v0.6.4) (Jul. 20, 2021) or earlier.
272278

273-
279+
[0.11.14]: https://github.com/PSLmodels/OG-Core/compare/v0.11.13...v0.11.14
274280
[0.11.13]: https://github.com/PSLmodels/OG-Core/compare/v0.11.11...v0.11.13
275281
[0.11.11]: https://github.com/PSLmodels/OG-Core/compare/v0.11.10...v0.11.11
276282
[0.11.10]: https://github.com/PSLmodels/OG-Core/compare/v0.11.9...v0.11.10

ogcore/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@
2020
from ogcore.txfunc import *
2121
from ogcore.utils import *
2222

23-
__version__ = "0.11.13"
23+
__version__ = "0.11.14"

ogcore/demographics.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -206,19 +206,23 @@ def get_fert(
206206

207207
# Create plots if needed
208208
if graph:
209+
if start_year == end_year:
210+
years_to_plot = [start_year]
211+
else:
212+
years_to_plot = [start_year, end_year]
209213
if plot_path is not None:
210214
pp.plot_fert_rates(
211215
[fert_rates_2D],
212216
start_year=start_year,
213-
years_to_plot=[start_year, end_year],
217+
years_to_plot=years_to_plot,
214218
path=plot_path,
215219
)
216220
return fert_rates_2D
217221
else:
218222
fig = pp.plot_fert_rates(
219223
[fert_rates_2D],
220224
start_year=start_year,
221-
years_to_plot=[start_year, end_year],
225+
years_to_plot=years_to_plot,
222226
)
223227
return fert_rates_2D, fig
224228
else:
@@ -296,19 +300,23 @@ def get_mort(
296300

297301
# Create plots if needed
298302
if graph:
303+
if start_year == end_year:
304+
years_to_plot = [start_year]
305+
else:
306+
years_to_plot = [start_year, end_year]
299307
if plot_path is not None:
300308
pp.plot_mort_rates_data(
301309
mort_rates_2D,
302310
start_year,
303-
[start_year, end_year],
311+
years_to_plot,
304312
path=plot_path,
305313
)
306314
return mort_rates_2D, infmort_rate_vec
307315
else:
308316
fig = pp.plot_mort_rates_data(
309317
mort_rates_2D,
310318
start_year,
311-
[start_year, end_year],
319+
years_to_plot,
312320
)
313321
return mort_rates_2D, infmort_rate_vec, fig
314322
else:
@@ -631,19 +639,23 @@ def get_imm_rates(
631639

632640
# Create plots if needed
633641
if graph:
642+
if start_year == end_year:
643+
years_to_plot = [start_year]
644+
else:
645+
years_to_plot = [start_year, end_year]
634646
if plot_path is not None:
635647
pp.plot_imm_rates(
636648
imm_rates_2D,
637649
start_year,
638-
[start_year, end_year],
650+
years_to_plot,
639651
path=plot_path,
640652
)
641653
return imm_rates_2D
642654
else:
643655
fig = pp.plot_imm_rates(
644656
imm_rates_2D,
645657
start_year,
646-
[start_year, end_year],
658+
years_to_plot,
647659
)
648660
return imm_rates_2D, fig
649661
else:

ogcore/parameter_plots.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import os
44
import matplotlib.pyplot as plt
55
import matplotlib
6-
from cycler import cycler
76
from ogcore.constants import GROUP_LABELS
87
from ogcore import utils, txfunc
98
from ogcore.constants import DEFAULT_START_YEAR, VAR_LABELS
@@ -34,7 +33,6 @@ def plot_imm_rates(
3433
3534
"""
3635
# create line styles to cycle through
37-
plt.rc("axes", prop_cycle=(cycler("linestyle", [":", "-.", "-", "--"])))
3836
fig, ax = plt.subplots()
3937
for y in years_to_plot:
4038
i = start_year - y
@@ -46,7 +44,7 @@ def plot_imm_rates(
4644
plt.legend(loc="upper left")
4745
plt.text(
4846
-5,
49-
-0.023,
47+
-0.05,
5048
"Source: " + source,
5149
fontsize=9,
5250
)
@@ -258,7 +256,7 @@ def plot_ability_profiles(
258256
return fig
259257
else:
260258
fig_path = os.path.join(path, "ability_profiles")
261-
plt.savefig(fig_path, bbox_inches="tight")
259+
plt.savefig(fig_path, bbox_inches="tight", dpi=300)
262260

263261

264262
def plot_elliptical_u(p, plot_MU=True, include_title=False, path=None):
@@ -389,7 +387,6 @@ def plot_fert_rates(
389387
390388
"""
391389
# create line styles to cycle through
392-
plt.rc("axes", prop_cycle=(cycler("linestyle", [":", "-.", "-", "--"])))
393390
fig, ax = plt.subplots()
394391
for y in years_to_plot:
395392
i = start_year - y
@@ -441,7 +438,6 @@ def plot_mort_rates_data(
441438
442439
"""
443440
# create line styles to cycle through
444-
plt.rc("axes", prop_cycle=(cycler("linestyle", [":", "-.", "-", "--"])))
445441
fig, ax = plt.subplots()
446442
for y in years_to_plot:
447443
i = start_year - y
@@ -706,7 +702,7 @@ def gen_3Dscatters_hist(df, s, t, output_dir):
706702
)
707703
filename = "ETR_age_" + str(s) + "_Year_" + str(t) + "_data.png"
708704
fullpath = os.path.join(output_dir, filename)
709-
fig.savefig(fullpath, bbox_inches="tight")
705+
fig.savefig(fullpath, bbox_inches="tight", dpi=300)
710706
plt.close()
711707

712708
# Plot 3D histogram for all data
@@ -737,7 +733,7 @@ def gen_3Dscatters_hist(df, s, t, output_dir):
737733
)
738734
filename = "Hist_Age_" + str(s) + "_Year_" + str(t) + ".png"
739735
fullpath = os.path.join(output_dir, filename)
740-
fig.savefig(fullpath, bbox_inches="tight")
736+
fig.savefig(fullpath, bbox_inches="tight", dpi=300)
741737
plt.close()
742738

743739
# Plot 3D scatterplot of MTRx data
@@ -755,7 +751,7 @@ def gen_3Dscatters_hist(df, s, t, output_dir):
755751
)
756752
filename = "MTRx_Age_" + str(s) + "_Year_" + str(t) + "_data.png"
757753
fullpath = os.path.join(output_dir, filename)
758-
fig.savefig(fullpath, bbox_inches="tight")
754+
fig.savefig(fullpath, bbox_inches="tight", dpi=300)
759755
plt.close()
760756

761757
# Plot 3D scatterplot of MTRy data
@@ -773,7 +769,7 @@ def gen_3Dscatters_hist(df, s, t, output_dir):
773769
)
774770
filename = "MTRy_Age_" + str(s) + "_Year_" + str(t) + "_data.png"
775771
fullpath = os.path.join(output_dir, filename)
776-
fig.savefig(fullpath, bbox_inches="tight")
772+
fig.savefig(fullpath, bbox_inches="tight", dpi=300)
777773
plt.close()
778774

779775
# Garbage collection
@@ -855,7 +851,7 @@ def txfunc_graph(
855851
ax.plot_surface(X_grid, Y_grid, txrate_grid, cmap=cmap1, linewidth=0)
856852
filename = tx_label + "_age_" + str(s) + "_Year_" + str(t) + "_vsPred.png"
857853
fullpath = os.path.join(output_dir, filename)
858-
fig.savefig(fullpath, bbox_inches="tight")
854+
fig.savefig(fullpath, bbox_inches="tight", dpi=300)
859855
plt.close()
860856

861857
# Make comparison plot with truncated income domains
@@ -908,7 +904,7 @@ def txfunc_graph(
908904
tx_label + "trunc_age_" + str(s) + "_Year_" + str(t) + "_vsPred.png"
909905
)
910906
fullpath = os.path.join(output_dir, filename)
911-
fig.savefig(fullpath, bbox_inches="tight")
907+
fig.savefig(fullpath, bbox_inches="tight", dpi=300)
912908
plt.close()
913909

914910

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setuptools.setup(
77
name="ogcore",
8-
version="0.11.13",
8+
version="0.11.14",
99
author="Jason DeBacker and Richard W. Evans",
1010
license="CC0 1.0 Universal (CC0 1.0) Public Domain Dedication",
1111
description="A general equilibribum overlapping generations model for fiscal policy analysis",

0 commit comments

Comments
 (0)