I want to add a title to my figure that contains several subplots.
Here is my code:
import matplotlib.pyplot as plt
plt.figure(figsize = (15, 80))
for i, audio, rate, name in zip(range(len(audios)), audios, rates, names):
plt.subplot(len(audios), 1, i+1)
plt.plot(rate, audio)
plt.xlabel('Time (s)')
plt.ylabel('Amplitude')
plt.title(name)
plt.subtitle('Figure 1: Plot amplitude of signal')
plt.show()
The error I get is : module 'matplotlib.pyplot' has no attribute 'subtitle'
I can't figure out why this doesn't work since it is written that way in the matplotlib documentation ! Thank you for your help.
The error is correct, the pyplot
library has no .su title
function, only a .su title
function . title功能,只有一个.su title
功能。
So you should fix this with:
import matplotlib.pyplot as plt
plt.figure(figsize = (15, 80))
for i, audio, rate, name in zip(range(len(audios)), audios, rates, names):
plt.subplot(len(audios), 1, i+1)
plt.plot(rate, audio)
plt.xlabel('Time (s)')
plt.ylabel('Amplitude')
plt.title(name)
plt.('Figure 1: Plot amplitude of signal')
plt.show()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.