Skip to content

Commit a173426

Browse files
committed
BUG: Fix Incompatible argument type for set_xlabel and set_ylabel.
1 parent 1d88e84 commit a173426

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

pandas/plotting/_matplotlib/hist.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -201,16 +201,18 @@ def _get_column_weights(weights, i: int, y):
201201

202202
def _post_plot_logic(self, ax: Axes, data) -> None:
203203
if self.orientation == "horizontal":
204-
# error: Argument 1 to "set_xlabel" of "_AxesBase" has incompatible
205-
# type "Hashable"; expected "str"
206204
ax.set_xlabel(
207-
"Frequency" if self.xlabel is None else self.xlabel # type: ignore[arg-type]
205+
"Frequency" if self.xlabel is None else str(self.xlabel) # type: ignore[arg-type]
206+
)
207+
ax.set_ylabel(
208+
self.ylabel if isinstance(self.ylabel, str) else str(self.ylabel) # type: ignore[arg-type]
208209
)
209-
ax.set_ylabel(self.ylabel) # type: ignore[arg-type]
210210
else:
211-
ax.set_xlabel(self.xlabel) # type: ignore[arg-type]
211+
ax.set_xlabel(
212+
self.xlabel if isinstance(self.xlabel, str) else str(self.xlabel) # type: ignore[arg-type]
213+
)
212214
ax.set_ylabel(
213-
"Frequency" if self.ylabel is None else self.ylabel # type: ignore[arg-type]
215+
"Frequency" if self.ylabel is None else ylabel # type: ignore[arg-type]
214216
)
215217

216218
@property

0 commit comments

Comments
 (0)