Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d5f9876

Browse files
committed
Merge pull request matplotlib#2522 from toddrjen/spectrum
Add additional spectrum-related plots and improve underlying structure
2 parents 0161fe2 + 4d9cc28 commit d5f9876

29 files changed

+4702
-462
lines changed

CHANGELOG

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
2013-10-06 Add stride-based functions to mlab for easy creation of 2D arrays
2+
with less memory.
3+
4+
2013-10-06 Improve window and detrend functions in mlab, particulart support for
5+
2D arrays.
6+
7+
2013-10-06 Improve performance of all spectrum-related mlab functions and plots.
8+
9+
2013-10-06 Added support for magnitude, phase, and angle spectrums to
10+
axes.specgram, and support for magnitude, phase, angle, and complex
11+
spectrums to mlab-specgram.
12+
13+
2013-10-06 Added magnitude_spectrum, angle_spectrum, and phase_spectrum plots,
14+
as well as magnitude_spectrum, angle_spectrum, phase_spectrum,
15+
and complex_spectrum functions to mlab
16+
117
2013-07-12 Added support for datetime axes to 2d plots. Axis values are passed
218
through Axes.convert_xunits/Axes.convert_yunits before being used by
319
contour/contourf, pcolormesh and pcolor.

boilerplate.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ def boilerplate_gen():
9898
# name.
9999
_plotcommands = (
100100
'acorr',
101+
'angle_spectrum',
101102
'arrow',
102103
'axhline',
103104
'axhspan',
@@ -123,8 +124,10 @@ def boilerplate_gen():
123124
'hlines',
124125
'imshow',
125126
'loglog',
127+
'magnitude_spectrum',
126128
'pcolor',
127129
'pcolormesh',
130+
'phase_spectrum',
128131
'pie',
129132
'plot',
130133
'plot_date',

doc/api/api_changes.rst

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,28 @@ original location:
7676
- `xycoords` -> set the units of the point location
7777
- `set_position()` -> `Annotation` only set location of annotation
7878

79+
* NFFT being even is now enforced in `matplotlib.mlab.specgram`,
80+
`matplotlib.mlab.psd`, `matplotlib.mlab.csd`,
81+
`matplotlib.mlab.cohere`, `matplotlib.mlab.cohere_pairs`,
82+
`matplotlib.pyplot.specgram`, `matplotlib.pyplot.psd`,
83+
`matplotlib.pyplot.csd`, and `matplotlib.pyplot.cohere`. This was
84+
listed as a requirement but was not actually checked.
85+
86+
* `matplotlib.mlab.specgram`, `matplotlib.mlab.psd`, `matplotlib.mlab.csd`,
87+
`matplotlib.mlab.cohere`, `matplotlib.mlab.cohere_pairs`,
88+
`matplotlib.pyplot.specgram`, `matplotlib.pyplot.psd`,
89+
`matplotlib.pyplot.csd`, and `matplotlib.pyplot.cohere` now raise
90+
ValueError where they previously raised AssertionError.
91+
92+
* For `matplotlib.mlab.psd`, `matplotlib.mlab.csd`,
93+
`matplotlib.mlab.cohere`, `matplotlib.mlab.cohere_pairs`,
94+
`matplotlib.pyplot.specgram`, `matplotlib.pyplot.psd`,
95+
`matplotlib.pyplot.csd`, and `matplotlib.pyplot.cohere`, in cases
96+
where a shape (n, 1) array is returned, this is now converted to a (n, )
97+
array. Previously, (n, m) arrays were averaged to an (n, ) array, but
98+
(n, 1) arrays were returend unchanged. This change makes the dimensions
99+
consistent in both cases.
100+
79101

80102
.. _changes_in_1_3:
81103

doc/users/whats_new.rst

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,36 @@ Andrew Dawson added support for datetime axes to
3232
:func:`~matplotlib.pyplot.contour`, :func:`~matplotlib.pyplot.contourf`,
3333
:func:`~matplotlib.pyplot.pcolormesh` and :func:`~matplotlib.pyplot.pcolor`.
3434

35+
Support for additional spectrum types
36+
`````````````````````````````````````
37+
Todd Jennings added support for new types of frequency spectrum plots:
38+
:func:`~matplotlib.pyplot.magnitude_spectrum`,
39+
:func:`~matplotlib.pyplot.phase_spectrum`, and
40+
:func:`~matplotlib.pyplot.angle_spectrum`, as well as corresponding functions
41+
in mlab.
42+
43+
He also added these spectrum types to :func:`~matplotlib.pyplot.specgram`,
44+
as well as adding support for linear scaling there (in addition to the
45+
existing dB scaling). Support for additional spectrum types was also added to
46+
:func:`~matplotlib.mlab.specgram`.
47+
48+
He also increased the performance for all of these functions and plot types.
49+
50+
Support for detrending and windowing 2D arrays in mlab
51+
``````````````````````````````````````````````````````
52+
Todd Jennings added support for 2D arrays in the
53+
:func:`~matplotlib.mlab.detrend_mean`, :func:`~matplotlib.mlab.detrend_none`,
54+
and :func:`~matplotlib.mlab.detrend`, as well as adding
55+
:func:`~matplotlib.mlab.apply_window` which support windowing 2D arrays.
56+
57+
Support for strides in mlab
58+
```````````````````````````
59+
Todd Jennings added some functions to mlab to make it easier to use numpy
60+
strides to create memory-efficient 2D arrays. This includes
61+
:func:`~matplotlib.mlab.stride_repeat`, which repeats an array to create a 2D
62+
array, and :func:`~matplotlib.mlab.stride_windows`, which uses a moving window
63+
to create a 2D array from a 1D array.
64+
3565

3666
Date handling
3767
-------------
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env python
2+
# python
3+
4+
from pylab import *
5+
6+
dt = 0.01
7+
Fs = 1/dt
8+
t = arange(0, 10, dt)
9+
nse = randn(len(t))
10+
r = exp(-t/0.05)
11+
12+
cnse = convolve(nse, r)*dt
13+
cnse = cnse[:len(t)]
14+
s = 0.1*sin(2*pi*t) + cnse
15+
16+
subplot(3, 2, 1)
17+
plot(t, s)
18+
19+
subplot(3, 2, 3)
20+
magnitude_spectrum(s, Fs=Fs)
21+
22+
subplot(3, 2, 4)
23+
magnitude_spectrum(s, Fs=Fs, scale='dB')
24+
25+
subplot(3, 2, 5)
26+
angle_spectrum(s, Fs=Fs)
27+
28+
subplot(3, 2, 6)
29+
phase_spectrum(s, Fs=Fs)
30+
31+
show()

0 commit comments

Comments
 (0)