0

I'm trying to produce a stacked set of waveform plots to include in a paper, and my desired font is Helvetica, which is applied to the x-axis values and labels but not to the y-axis values. An additional issue I'm having is the repeated x-axis labels, as I only wish to have time labelled on the bottom plot. Here is my code:

from matplotlib import rc
import matplotlib.pyplot as plt

rc('font', **{'family': 'sans-serif', 'sans-serif': ['Helvetica']})
rc('text', usetex=True)

ref, sr = librosa.load(r"C:\Users\...\ref_4_dry.wav", mono=False, duration=10, sr=44100)

wn, sr = librosa.load(r"C:\Users\...\wn_4_dry.wav", mono=False, duration=10, sr=44100)

mwn, sr = librosa.load(r"C:\Users\...\mwn_4_dry.wav", mono=False, duration=10, sr=44100)

fig, ax =  plt.subplots(nrows=3, sharex=True, figsize=(15, 15))
    
librosa.display.waveshow(ref, sr=sr, ax=ax[0])
librosa.display.waveshow(wn, sr=sr, ax=ax[1])
librosa.display.waveshow(mwn, sr=sr, ax=ax[2])

Here is an image of the issue I'm having (the y-axis font seems to be reverting to Computer Modern or some other standard font): enter image description here

Brudalaxe
  • 191
  • 1
  • 8
  • 2
    Does this answer your question? [Sans-serif math with latex in matplotlib](https://stackoverflow.com/questions/2537868/sans-serif-math-with-latex-in-matplotlib) – Leonard Aug 13 '22 at 09:25
  • Thank you @Leonard, this has sorted out the font style issue, however I'm still encountering the problem with the repeated x-axis labels – Brudalaxe Aug 13 '22 at 09:31
  • `ax[0].set_xlabel('')` or `ax[0].label_outer()`, same for `ax[1]` – Stef Aug 13 '22 at 09:46

0 Answers0