diff --git a/drees.py b/drees.py index bb185b2..7e1dfe4 100644 --- a/drees.py +++ b/drees.py @@ -289,6 +289,7 @@ def get_plot_fig( date_format: Optional[str] = DATE_FORMAT, figsize: Optional[Tuple[int, int]] = None, locator: Optional[Any] = md.MonthLocator(), + auto_date_fmt: Optional[bool] = True, ) -> plt.figure: """ return pyplot fig, ax to plot data over range period with date formatting @@ -298,7 +299,8 @@ def get_plot_fig( date_formatter = md.DateFormatter(date_format) ax.xaxis.set_major_locator(locator) ax.xaxis.set_major_formatter(date_formatter) - fig.autofmt_xdate() + if auto_date_fmt: + fig.autofmt_xdate() return fig, ax @@ -444,7 +446,7 @@ def plot_cumulative_field( """ np_data_vac, np_data_unvac = split_by_vac_status(np_data) for age_group in AgeGroup: - fig, _ = get_plot_fig() + fig, _ = get_plot_fig(auto_date_fmt=False) np_cumulate_vac: np.ndarray = np.cumsum( np_data_vac[:, age_group.value, field.value], axis=0 ) @@ -457,6 +459,7 @@ def plot_cumulative_field( plt.title(f"{age_group.label} - {field.label}") plt.xlabel("Date") plt.ylabel("Nombre de cas") + plt.xticks(rotation=30) save_and_close_fig( fig, os.path.join( @@ -472,7 +475,7 @@ def plot_fields_by_age_vac( """ plot field data by age and vaccine status (cases per million) """ - fig, _ = get_plot_fig() + fig, _ = get_plot_fig(auto_date_fmt=False) for field in Field: np_result = ( @@ -485,6 +488,7 @@ def plot_fields_by_age_vac( ) plt.xlabel("Date") plt.ylabel("Cas par million de personnes") + plt.xticks(rotation=30) plt.title(f"{age_group.label} - {vac_status.label}") save_and_close_fig(