Repository: librosa/librosa

Issue:
Plot subtitle and ticks overlap
**Describe the bug**
In version 0.10.0, for the following functions/examples, the included example plot's subtitles and axis ticks are overlapping with each other:

https://librosa.org/doc/main/generated/librosa.sequence.dtw.html#librosa.sequence.dtw
https://librosa.org/doc/main/generated/librosa.feature.mfcc.html
https://librosa.org/doc/main/generated/librosa.filters.wavelet.html
https://librosa.org/doc/main/generated/librosa.filters.window_sumsquare.html
https://librosa.org/doc/main/auto_examples/plot_music_sync.html

In version 0.9.2, the issue is not present in any of the cases.
Plot subtitle and ticks overlap
**Describe the bug**
In version 0.10.0, for the following functions/examples, the included example plot's subtitles and axis ticks are overlapping with each other:

https://librosa.org/doc/main/generated/librosa.sequence.dtw.html#librosa.sequence.dtw
https://librosa.org/doc/main/generated/librosa.feature.mfcc.html
https://librosa.org/doc/main/generated/librosa.filters.wavelet.html
https://librosa.org/doc/main/generated/librosa.filters.window_sumsquare.html
https://librosa.org/doc/main/auto_examples/plot_music_sync.html

In version 0.9.2, the issue is not present in any of the cases.


Discussion:
Thanks for catching these.  I'm not yet sure why it's happening, but it's good that it seems confined to the development builds for now.
Aha!  I see what's happening here.  It's down to this line:

https://github.com/librosa/librosa/blob/96f8beeea7253ebe0b7606d1cbec359a30ae3b6b/docs/conf.py#L101

This worked fine when the version numbers were lexically sorted (`'0.9' > '0.8'`) but fails once we get to `'0.10.0...'`.  As a result, the docs are not setting `constrained_layout`.

The good news is that this is no longer necessary, as our oldest doc build is now 0.8, so we can unequivocally set this to `True` and the problem should resolve itself.  I'll get a PR going.
Thanks for catching these.  I'm not yet sure why it's happening, but it's good that it seems confined to the development builds for now.
Aha!  I see what's happening here.  It's down to this line:

https://github.com/librosa/librosa/blob/96f8beeea7253ebe0b7606d1cbec359a30ae3b6b/docs/conf.py#L101

This worked fine when the version numbers were lexically sorted (`'0.9' > '0.8'`) but fails once we get to `'0.10.0...'`.  As a result, the docs are not setting `constrained_layout`.

The good news is that this is no longer necessary, as our oldest doc build is now 0.8, so we can unequivocally set this to `True` and the problem should resolve itself.  I'll get a PR going.

Resolving patch:
diff --git a/docs/conf.py b/docs/conf.py
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -98,7 +98,7 @@
 import matplotlib
 import librosa
 import librosa.display
-matplotlib.rcParams['figure.constrained_layout.use'] = librosa.__version__ >= '0.8'
+matplotlib.rcParams['figure.constrained_layout.use'] = True
 """
 )
 plot_include_source = True
@@ -139,7 +139,7 @@ def reset_mpl(gallery_conf, fname):
     matplotlib.rcParams.update(**plot_rcparams)
 
     # Only use constrained layout in 0.8 and above
-    matplotlib.rcParams['figure.constrained_layout.use'] = librosa.__version__ >= '0.8'
+    matplotlib.rcParams['figure.constrained_layout.use'] = True
     plt.close('all')
 
 
diff --git a/docs/examples/plot_music_sync.py b/docs/examples/plot_music_sync.py
--- a/docs/examples/plot_music_sync.py
+++ b/docs/examples/plot_music_sync.py
@@ -94,7 +94,7 @@
 # (Thanks to F. Zalkow for the nice visualization.)
 from matplotlib.patches import ConnectionPatch
 
-fig, (ax1, ax2) = plt.subplots(nrows=2, sharex=True, sharey=True, figsize=(8, 4))
+fig, (ax1, ax2) = plt.subplots(nrows=2, sharex=True, sharey=True, figsize=(8,4))
 
 # Plot x_2
 librosa.display.waveshow(x_2, sr=fs, ax=ax2)
@@ -115,6 +115,7 @@
                           coordsA='data', coordsB='data',
                           color='r', linestyle='--',
                           alpha=0.5)
+    con.set_in_layout(False)  # This is needed to preserve layout
     ax2.add_artist(con)
 
 ###########################################################


Test patch: