diff --git a/CHANGELOG.md b/CHANGELOG.md index 1817cddc7..af23aa948 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.11.14] - 2024-07-30 12:00:00 + +### Added + +- Aesthetic updates to plotting functions in `parameter_plots.py` and `demographics.py` + ## [0.11.13] - 2024-07-28 12:00:00 ### Added @@ -270,7 +276,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - 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. - 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. - +[0.11.14]: https://github.com/PSLmodels/OG-Core/compare/v0.11.13...v0.11.14 [0.11.13]: https://github.com/PSLmodels/OG-Core/compare/v0.11.11...v0.11.13 [0.11.11]: https://github.com/PSLmodels/OG-Core/compare/v0.11.10...v0.11.11 [0.11.10]: https://github.com/PSLmodels/OG-Core/compare/v0.11.9...v0.11.10 diff --git a/ogcore/__init__.py b/ogcore/__init__.py index 234c048f7..3d7193455 100644 --- a/ogcore/__init__.py +++ b/ogcore/__init__.py @@ -20,4 +20,4 @@ from ogcore.txfunc import * from ogcore.utils import * -__version__ = "0.11.13" +__version__ = "0.11.14" diff --git a/ogcore/demographics.py b/ogcore/demographics.py index c223e2b60..ce07abdfd 100644 --- a/ogcore/demographics.py +++ b/ogcore/demographics.py @@ -206,11 +206,15 @@ def get_fert( # Create plots if needed if graph: + if start_year == end_year: + years_to_plot = [start_year] + else: + years_to_plot = [start_year, end_year] if plot_path is not None: pp.plot_fert_rates( [fert_rates_2D], start_year=start_year, - years_to_plot=[start_year, end_year], + years_to_plot=years_to_plot, path=plot_path, ) return fert_rates_2D @@ -218,7 +222,7 @@ def get_fert( fig = pp.plot_fert_rates( [fert_rates_2D], start_year=start_year, - years_to_plot=[start_year, end_year], + years_to_plot=years_to_plot, ) return fert_rates_2D, fig else: @@ -296,11 +300,15 @@ def get_mort( # Create plots if needed if graph: + if start_year == end_year: + years_to_plot = [start_year] + else: + years_to_plot = [start_year, end_year] if plot_path is not None: pp.plot_mort_rates_data( mort_rates_2D, start_year, - [start_year, end_year], + years_to_plot, path=plot_path, ) return mort_rates_2D, infmort_rate_vec @@ -308,7 +316,7 @@ def get_mort( fig = pp.plot_mort_rates_data( mort_rates_2D, start_year, - [start_year, end_year], + years_to_plot, ) return mort_rates_2D, infmort_rate_vec, fig else: @@ -631,11 +639,15 @@ def get_imm_rates( # Create plots if needed if graph: + if start_year == end_year: + years_to_plot = [start_year] + else: + years_to_plot = [start_year, end_year] if plot_path is not None: pp.plot_imm_rates( imm_rates_2D, start_year, - [start_year, end_year], + years_to_plot, path=plot_path, ) return imm_rates_2D @@ -643,7 +655,7 @@ def get_imm_rates( fig = pp.plot_imm_rates( imm_rates_2D, start_year, - [start_year, end_year], + years_to_plot, ) return imm_rates_2D, fig else: diff --git a/ogcore/parameter_plots.py b/ogcore/parameter_plots.py index 15f18b3fd..78a83d25e 100644 --- a/ogcore/parameter_plots.py +++ b/ogcore/parameter_plots.py @@ -3,7 +3,6 @@ import os import matplotlib.pyplot as plt import matplotlib -from cycler import cycler from ogcore.constants import GROUP_LABELS from ogcore import utils, txfunc from ogcore.constants import DEFAULT_START_YEAR, VAR_LABELS @@ -34,7 +33,6 @@ def plot_imm_rates( """ # create line styles to cycle through - plt.rc("axes", prop_cycle=(cycler("linestyle", [":", "-.", "-", "--"]))) fig, ax = plt.subplots() for y in years_to_plot: i = start_year - y @@ -46,7 +44,7 @@ def plot_imm_rates( plt.legend(loc="upper left") plt.text( -5, - -0.023, + -0.05, "Source: " + source, fontsize=9, ) @@ -258,7 +256,7 @@ def plot_ability_profiles( return fig else: fig_path = os.path.join(path, "ability_profiles") - plt.savefig(fig_path, bbox_inches="tight") + plt.savefig(fig_path, bbox_inches="tight", dpi=300) def plot_elliptical_u(p, plot_MU=True, include_title=False, path=None): @@ -389,7 +387,6 @@ def plot_fert_rates( """ # create line styles to cycle through - plt.rc("axes", prop_cycle=(cycler("linestyle", [":", "-.", "-", "--"]))) fig, ax = plt.subplots() for y in years_to_plot: i = start_year - y @@ -441,7 +438,6 @@ def plot_mort_rates_data( """ # create line styles to cycle through - plt.rc("axes", prop_cycle=(cycler("linestyle", [":", "-.", "-", "--"]))) fig, ax = plt.subplots() for y in years_to_plot: i = start_year - y @@ -706,7 +702,7 @@ def gen_3Dscatters_hist(df, s, t, output_dir): ) filename = "ETR_age_" + str(s) + "_Year_" + str(t) + "_data.png" fullpath = os.path.join(output_dir, filename) - fig.savefig(fullpath, bbox_inches="tight") + fig.savefig(fullpath, bbox_inches="tight", dpi=300) plt.close() # Plot 3D histogram for all data @@ -737,7 +733,7 @@ def gen_3Dscatters_hist(df, s, t, output_dir): ) filename = "Hist_Age_" + str(s) + "_Year_" + str(t) + ".png" fullpath = os.path.join(output_dir, filename) - fig.savefig(fullpath, bbox_inches="tight") + fig.savefig(fullpath, bbox_inches="tight", dpi=300) plt.close() # Plot 3D scatterplot of MTRx data @@ -755,7 +751,7 @@ def gen_3Dscatters_hist(df, s, t, output_dir): ) filename = "MTRx_Age_" + str(s) + "_Year_" + str(t) + "_data.png" fullpath = os.path.join(output_dir, filename) - fig.savefig(fullpath, bbox_inches="tight") + fig.savefig(fullpath, bbox_inches="tight", dpi=300) plt.close() # Plot 3D scatterplot of MTRy data @@ -773,7 +769,7 @@ def gen_3Dscatters_hist(df, s, t, output_dir): ) filename = "MTRy_Age_" + str(s) + "_Year_" + str(t) + "_data.png" fullpath = os.path.join(output_dir, filename) - fig.savefig(fullpath, bbox_inches="tight") + fig.savefig(fullpath, bbox_inches="tight", dpi=300) plt.close() # Garbage collection @@ -855,7 +851,7 @@ def txfunc_graph( ax.plot_surface(X_grid, Y_grid, txrate_grid, cmap=cmap1, linewidth=0) filename = tx_label + "_age_" + str(s) + "_Year_" + str(t) + "_vsPred.png" fullpath = os.path.join(output_dir, filename) - fig.savefig(fullpath, bbox_inches="tight") + fig.savefig(fullpath, bbox_inches="tight", dpi=300) plt.close() # Make comparison plot with truncated income domains @@ -908,7 +904,7 @@ def txfunc_graph( tx_label + "trunc_age_" + str(s) + "_Year_" + str(t) + "_vsPred.png" ) fullpath = os.path.join(output_dir, filename) - fig.savefig(fullpath, bbox_inches="tight") + fig.savefig(fullpath, bbox_inches="tight", dpi=300) plt.close() diff --git a/setup.py b/setup.py index 0b111a027..bd872c254 100755 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setuptools.setup( name="ogcore", - version="0.11.13", + version="0.11.14", author="Jason DeBacker and Richard W. Evans", license="CC0 1.0 Universal (CC0 1.0) Public Domain Dedication", description="A general equilibribum overlapping generations model for fiscal policy analysis",