Fix layout of spectrum_demo.py #8158

Merged
merged 3 commits into from Mar 6, 2017

Conversation

Projects
None yet
6 participants
Contributor

vollbier commented Feb 26, 2017

Fixes eighth entry in issue #7956

Contributor

anntzer commented Feb 27, 2017

  • Any reason why you swapped the angle and phase plots?
  • I would remove the $t$ and $s(t)$ unless you want to add similar labels for all subplots.
examples/pylab_examples/spectrum_demo.py
-plt.subplot(3, 2, 4)
-plt.magnitude_spectrum(s, Fs=Fs, scale='dB')
+fig, axx = plt.subplots(3, 2)
@phobson

phobson Feb 27, 2017

Member

I see what you're doing here. But I think we should strive for consistency in the examples/gallery.

In my mind that means, for a single axes object:

fig, ax = plt.subplots()

And for multiples axes:

fig, axes = plt.subplots(ncols=C, nrows=R)
examples/pylab_examples/spectrum_demo.py
+# plot different spectrum types:
+axx[1, 0].magnitude_spectrum(s, Fs=Fs)
+axx[2, 0].phase_spectrum(s, Fs=Fs)
+axx[0, 1].remove() # don't display empty ax
@phobson

phobson Feb 27, 2017

Member

perhaps move this to the end.

@vollbier

vollbier Feb 28, 2017

Contributor

Good points - fixed them.

Contributor

vollbier commented Feb 28, 2017

@anntzer I swapped the plots around for aesthetic reasons: The minus signs in the y-axis changes the position of the y-labels. $t$ and $s(t)$ are removed.
Furthermore, I would argue that for a correct energy the scaling of the spectrum is of by a factor of 1/Fs or so. I'll investigate that a bit more and put that into a different pull request.

examples/pylab_examples/spectrum_demo.py
-plt.subplot(3, 2, 6)
-plt.phase_spectrum(s, Fs=Fs)
+# plot different spectrum types:
@tacaswell

tacaswell Mar 1, 2017

Owner

might be worth giving them titles / axis labels?

@phobson

phobson Mar 1, 2017 edited

Member

@vollbier sorry to move the goal post on you.

In addition to Tom's request could you:

  1. make the figure bigger (add figsize=(7, 7) to the call to subplots)
    2) make the Magnitude y-axis log-scaled (if that's appropriate for the domain)
@vollbier

vollbier Mar 1, 2017

Contributor

I added titles, but I think it's worthwhile leaving the default axis labels, since it's feature of the spectrum functions.

examples/pylab_examples/spectrum_demo.py
-plt.subplot(3, 2, 6)
-plt.phase_spectrum(s, Fs=Fs)
+# plot different spectrum types:
@phobson

phobson Mar 1, 2017 edited

Member

@vollbier sorry to move the goal post on you.

In addition to Tom's request could you:

  1. make the figure bigger (add figsize=(7, 7) to the call to subplots)
    2) make the Magnitude y-axis log-scaled (if that's appropriate for the domain)

vollbier added some commits Feb 26, 2017

@vollbier vollbier Fix layout of spectrum_demo.py ac09d60
@vollbier vollbier Beautified spectrum_demo.py a little more. b88f58c
@vollbier vollbier Added plot titles to spectrum_demo.py
f2bc54b
@phobson

phobson approved these changes Mar 3, 2017

phobson changed the title from Fix layout of spectrum_demo.py to [MRG+1] Fix layout of spectrum_demo.py Mar 3, 2017

@NelleV NelleV merged commit a8547fa into matplotlib:master Mar 6, 2017

5 checks passed

codecov/patch Coverage not affected when comparing c2f675d...f2bc54b
Details
codecov/project/library 57.95% (+2.76%) compared to c2f675d
Details
codecov/project/tests 98.53% (target 97.9%)
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Contributor

NelleV commented Mar 6, 2017

Thanks @vollbier ! This is so much better!

vollbier deleted the vollbier:spectrum_demo branch Mar 6, 2017

anntzer referenced this pull request Mar 6, 2017

Open

Suggested improvements to the gallery #7956

12 of 16 tasks complete

QuLogic changed the title from [MRG+1] Fix layout of spectrum_demo.py to Fix layout of spectrum_demo.py Mar 6, 2017

QuLogic added this to the 2.1 (next point release) milestone Mar 6, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment