From 8f2d361e5fa65befb78750683fac81c1f20f71ee Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Thu, 20 Jun 2024 20:33:43 +0200 Subject: [PATCH] feat(script): Show all years for pubs per year figure --- scoping_review.qmd | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/scoping_review.qmd b/scoping_review.qmd index f0484d0..260b842 100644 --- a/scoping_review.qmd +++ b/scoping_review.qmd @@ -496,13 +496,16 @@ df_study_years = ( .first() .reset_index() .drop_duplicates() + ["year"].value_counts() + .sort_index() ) -# FIXME potentially timeseries plot so no years are missing -ax = sns.countplot(df_study_years, x="year") +# use order to ensure all years are displayed, even ones without values +years_range = list(range(df_study_years.index.min(), df_study_years.index.max()+1)) +ax = sns.barplot(df_study_years, order=years_range) -ax.tick_params(axis='x', rotation=45) ax.set_ylabel("Count") ax.set_xlabel("Year") +plt.setp(ax.get_xticklabels(), rotation=45, ha="right", rotation_mode="anchor") # ensure rotated right-anchor plt.tight_layout() plt.show() df_study_years = None