diff --git a/pandas/plotting/_matplotlib/hist.py b/pandas/plotting/_matplotlib/hist.py index 1a423ad49c294..49302d9bf0494 100644 --- a/pandas/plotting/_matplotlib/hist.py +++ b/pandas/plotting/_matplotlib/hist.py @@ -201,14 +201,16 @@ def _get_column_weights(weights, i: int, y): def _post_plot_logic(self, ax: Axes, data) -> None: if self.orientation == "horizontal": - # error: Argument 1 to "set_xlabel" of "_AxesBase" has incompatible - # type "Hashable"; expected "str" ax.set_xlabel( - "Frequency" if self.xlabel is None else self.xlabel # type: ignore[arg-type] + "Frequency" if self.xlabel is None else str(self.xlabel) # type: ignore[arg-type] + ) + ax.set_ylabel( + self.ylabel if isinstance(self.ylabel, str) else str(self.ylabel) # type: ignore[arg-type] ) - ax.set_ylabel(self.ylabel) # type: ignore[arg-type] else: - ax.set_xlabel(self.xlabel) # type: ignore[arg-type] + ax.set_xlabel( + self.xlabel if isinstance(self.xlabel, str) else str(self.xlabel) # type: ignore[arg-type] + ) ax.set_ylabel( "Frequency" if self.ylabel is None else self.ylabel # type: ignore[arg-type] )