rotate ticks date correctly (#3)
This commit is contained in:
parent
d674cf47eb
commit
7d5b692fae
10
drees.py
10
drees.py
@ -289,6 +289,7 @@ def get_plot_fig(
|
|||||||
date_format: Optional[str] = DATE_FORMAT,
|
date_format: Optional[str] = DATE_FORMAT,
|
||||||
figsize: Optional[Tuple[int, int]] = None,
|
figsize: Optional[Tuple[int, int]] = None,
|
||||||
locator: Optional[Any] = md.MonthLocator(),
|
locator: Optional[Any] = md.MonthLocator(),
|
||||||
|
auto_date_fmt: Optional[bool] = True,
|
||||||
) -> plt.figure:
|
) -> plt.figure:
|
||||||
"""
|
"""
|
||||||
return pyplot fig, ax to plot data over range period with date formatting
|
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)
|
date_formatter = md.DateFormatter(date_format)
|
||||||
ax.xaxis.set_major_locator(locator)
|
ax.xaxis.set_major_locator(locator)
|
||||||
ax.xaxis.set_major_formatter(date_formatter)
|
ax.xaxis.set_major_formatter(date_formatter)
|
||||||
fig.autofmt_xdate()
|
if auto_date_fmt:
|
||||||
|
fig.autofmt_xdate()
|
||||||
return fig, ax
|
return fig, ax
|
||||||
|
|
||||||
|
|
||||||
@ -444,7 +446,7 @@ def plot_cumulative_field(
|
|||||||
"""
|
"""
|
||||||
np_data_vac, np_data_unvac = split_by_vac_status(np_data)
|
np_data_vac, np_data_unvac = split_by_vac_status(np_data)
|
||||||
for age_group in AgeGroup:
|
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_cumulate_vac: np.ndarray = np.cumsum(
|
||||||
np_data_vac[:, age_group.value, field.value], axis=0
|
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.title(f"{age_group.label} - {field.label}")
|
||||||
plt.xlabel("Date")
|
plt.xlabel("Date")
|
||||||
plt.ylabel("Nombre de cas")
|
plt.ylabel("Nombre de cas")
|
||||||
|
plt.xticks(rotation=30)
|
||||||
save_and_close_fig(
|
save_and_close_fig(
|
||||||
fig,
|
fig,
|
||||||
os.path.join(
|
os.path.join(
|
||||||
@ -472,7 +475,7 @@ def plot_fields_by_age_vac(
|
|||||||
"""
|
"""
|
||||||
plot field data by age and vaccine status (cases per million)
|
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:
|
for field in Field:
|
||||||
np_result = (
|
np_result = (
|
||||||
@ -485,6 +488,7 @@ def plot_fields_by_age_vac(
|
|||||||
)
|
)
|
||||||
plt.xlabel("Date")
|
plt.xlabel("Date")
|
||||||
plt.ylabel("Cas par million de personnes")
|
plt.ylabel("Cas par million de personnes")
|
||||||
|
plt.xticks(rotation=30)
|
||||||
plt.title(f"{age_group.label} - {vac_status.label}")
|
plt.title(f"{age_group.label} - {vac_status.label}")
|
||||||
|
|
||||||
save_and_close_fig(
|
save_and_close_fig(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user