-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Closed
Copy link
Milestone
Description
Bug summary
When plotting bar charts in subplots with very long labels, the option of wrapping text only works on the first plotted subplot, despite passing wrap=True
to set_yticks()
in both cases.
Code for reproduction
import matplotlib.pyplot as plt
import numpy as np
long_text_label = 'very long category label i want to wrap'
labels = [f"{long_text_label}_{i}" for i in range(5)]
values = np.arange(1, 6)
fig, axes = plt.subplots(1, 2)
axes[0].barh(np.arange(len(labels)), values)
axes[0].set_yticks(np.arange(len(labels)), labels=labels, wrap=True)
axes[1].barh(np.arange(len(labels)), values)
axes[1].set_yticks(np.arange(len(labels)), labels=labels, wrap=True)
Actual outcome
Expected outcome
The label text on the y axis should appear wrapped on both subplots
Additional information
No response
Operating system
macOS 14.4 (23E214)
Matplotlib Version
3.8.3
Matplotlib Backend
module://matplotlib_inline.backend_inline
Python version
Python 3.11.8
Jupyter version
4.2.0
Installation
pip