今日『資料視覺化』之重要性,也許無須一再強調矣。因是
librosa 的使用者,自知
Display
specshow (data[, x_coords, y_coords, x_axis, …]) |
Display a spectrogram/chromagram/cqt/etc. |
waveplot (y[, sr, max_points, x_axis, …]) |
Plot the amplitude envelope of a waveform. |
cmap (data[, robust, cmap_seq, cmap_bool, …]) |
Get a default colormap from the given data. |
TimeFormatter ([lag]) |
A tick formatter for time axes. |
NoteFormatter ([octave, major]) |
Ticker formatter for Notes |
LogHzFormatter ([major]) |
Ticker formatter for logarithmic frequency |
ChromaFormatter |
A formatter for chroma axes |
TonnetzFormatter |
A formatter for tonnetz axes |
模組之不可或缺也。
自能善用
librosa.display.waveplot
librosa.display.
waveplot
(y, sr=22050, max_points=50000.0, x_axis=’time’, offset=0.0, max_sr=1000, **kwargs)- Plot the amplitude envelope of a waveform.
If y is monophonic, a filled curve is drawn between [-abs(y), abs(y)].
If y is stereo, the curve is drawn between [-abs(y[1]), abs(y[0])], so that the left and right channels are drawn above and below the axis, respectively.
Long signals (duration >= max_points) are down-sampled to at most max_sr before plotting.
Parameters: y : np.ndarray [shape=(n,) or (2,n)]
audio time series (mono or stereo)
sr : number > 0 [scalar]
sampling rate of y
max_points : postive number or None
Maximum number of time-points to plot: if max_points exceeds the duration of y, then y is downsampled.
If None, no downsampling is performed.
x_axis : str {‘time’, ‘off’, ‘none’} or None
If ‘time’, the x-axis is given time tick-marks.
offset : float
Horizontal offset (in time) to start the waveform plot
max_sr : number > 0 [scalar]
Maximum sampling rate for the visualization
kwargs
Additional keyword arguments to
matplotlib.pyplot.fill_between
Returns: pc : matplotlib.collections.PolyCollection
The PolyCollection created by fill_between.
以及
librosa.display.specshow
librosa.display.
specshow
(data, x_coords=None, y_coords=None, x_axis=None, y_axis=None, sr=22050, hop_length=512, fmin=None, fmax=None, bins_per_octave=12, **kwargs)- Display a spectrogram/chromagram/cqt/etc.
Parameters: data : np.ndarray [shape=(d, n)]
Matrix to display (e.g., spectrogram)
sr : number > 0 [scalar]
Sample rate used to determine time scale in x-axis.
hop_length : int > 0 [scalar]
Hop length, also used to determine time scale in x-axis
x_axis : None or str
y_axis : None or str
Range for the x- and y-axes.
Valid types are:
- None, ‘none’, or ‘off’ : no axis decoration is displayed.
Frequency types:
- ‘linear’, ‘fft’, ‘hz’ : frequency range is determined by the FFT window and sampling rate.
- ‘log’ : the spectrum is displayed on a log scale.
- ‘mel’ : frequencies are determined by the mel scale.
- ‘cqt_hz’ : frequencies are determined by the CQT scale.
- ‘cqt_note’ : pitches are determined by the CQT scale.
All frequency types are plotted in units of Hz.
Categorical types:
- ‘chroma’ : pitches are determined by the chroma filters. Pitch classes are arranged at integer locations (0-11).
- ‘tonnetz’ : axes are labeled by Tonnetz dimensions (0-5)
- ‘frames’ : markers are shown as frame counts.
Time types:
- ‘time’ : markers are shown as milliseconds, seconds, minutes, or hours
- ‘lag’ : like time, but past the half-way point counts as negative values.
All time types are plotted in units of seconds.
Other:
-
- ‘tempo’ : markers are shown as beats-per-minute (BPM)
- using a logarithmic scale.
x_coords : np.ndarray [shape=data.shape[1]+1]
y_coords : np.ndarray [shape=data.shape[0]+1]
Optional positioning coordinates of the input data. These can be use to explicitly set the location of each element data[i, j], e.g., for displaying beat-synchronous features in natural time coordinates.
If not provided, they are inferred from x_axis and y_axis.
fmin : float > 0 [scalar] or None
Frequency of the lowest spectrogram bin. Used for Mel and CQT scales.
If y_axis is cqt_hz or cqt_note and fmin is not given, it is set by default to note_to_hz(‘C1’).
fmax : float > 0 [scalar] or None
Used for setting the Mel frequency scales
bins_per_octave : int > 0 [scalar]
Number of bins per octave. Used for CQT frequency scale.
kwargs : additional keyword arguments
Arguments passed through to
matplotlib.pyplot.pcolormesh
.By default, the following options are set:
- rasterized=True
- shading=’flat’
- edgecolors=’None’
Returns: axes
The axis handle for the figure.
乎?惟勤作練習耶!