Skip to content

Commit

Permalink
create _adjust_axes_labels for axes labels
Browse files Browse the repository at this point in the history
  • Loading branch information
MAfarrag committed Aug 26, 2024
1 parent b21c07a commit d41b29b
Showing 1 changed file with 32 additions and 12 deletions.
44 changes: 32 additions & 12 deletions statista/time_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,17 @@ def _get_ax_fig(
fig = ax.figure
return fig, ax

@staticmethod
def _adjust_axes_labels(
ax: Axes, tick_labels: List[str], title: str, xlabel: str, ylabel: str
):
"""Adjust the labels of the axes."""
ax.set_xticklabels(tick_labels)
ax.set_title(title)
ax.set_xlabel(xlabel)
ax.set_ylabel(ylabel)
return ax

def box_plot(
self, mean: bool = False, notch: bool = False, **kwargs
) -> Tuple[Figure, Axes]:
Expand Down Expand Up @@ -237,10 +248,13 @@ def box_plot(
)
),
)
ax.set_xticklabels(self.columns)
ax.set_title(kwargs.get("title"))
ax.set_xlabel(kwargs.get("xlabel"))
ax.set_ylabel(kwargs.get("ylabel"))
ax = self._adjust_axes_labels(
ax,
self.columns,
kwargs.get("title"),
kwargs.get("xlabel"),
kwargs.get("ylabel"),
)

ax.grid(kwargs.get("grid"), axis="both", linestyle="-.", linewidth=0.3)
plt.show()
Expand Down Expand Up @@ -391,10 +405,13 @@ def violin(
pc.set_alpha(color.get("alpha"))

ax.xaxis.set_ticks(positions)
ax.set_xticklabels(self.columns)
ax.set_title(kwargs.get("title"))
ax.set_xlabel(kwargs.get("xlabel"))
ax.set_ylabel(kwargs.get("ylabel"))
ax = self._adjust_axes_labels(
ax,
self.columns,
kwargs.get("title"),
kwargs.get("xlabel"),
kwargs.get("ylabel"),
)

ax.grid(kwargs.get("grid"), axis="both", linestyle="-.", linewidth=0.3)
plt.show()
Expand Down Expand Up @@ -555,10 +572,13 @@ def raincloud(

# Set x-tick labels
ax.set_xticks(positions)
ax.set_xticklabels(self.columns)
ax.set_title(kwargs.get("title"))
ax.set_xlabel(kwargs.get("xlabel"))
ax.set_ylabel(kwargs.get("ylabel"))
ax = self._adjust_axes_labels(
ax,
self.columns,
kwargs.get("title"),
kwargs.get("xlabel"),
kwargs.get("ylabel"),
)

ax.grid(kwargs.get("grid"), axis="both", linestyle="-.", linewidth=0.3)

Expand Down

0 comments on commit d41b29b

Please sign in to comment.