很明显,没有什么有用的
y
手动设置标签时可以显示坐标;如果你认为你可以标出情节的话,那也许就更清楚了。
"Apple", "Banana", "Cherry"
-在这种情况下,当鼠标位于中间位置时,坐标是多少
"Banana"
和
"Cherry"
但是,您可以使用
FuncFormatter
设置勾选标签的格式。
import matplotlib.pyplot as plt
from matplotlib.ticker import FuncFormatter
import numpy as np
signal = np.sin(np.linspace(0,12,300))*.7
fig, ax = plt.subplots()
ax.set_title('Waveform and Spectrogram of a wav file')
ax.plot(signal)
ax.set_xlabel('Sample')
ax.set_ylabel('Amplitude (dB)')
def fmt(x,pos=None):
if x==0:
return "-inf"
else:
return '{:.1f}'.format(20*np.log10(np.sign(x)*x))
ax.yaxis.set_major_formatter(FuncFormatter(fmt))
plt.show()