Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Mep12 shared to spectrum #4659

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 12, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions 15 examples/pylab_examples/shared_axis_across_figures.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@
another. This is not the right way to do this for two axes in the
same figure -- use the sharex and sharey property in that case
"""
# -*- noplot -*-
import numpy
from pylab import figure, show
import numpy as np
import matplotlib.pyplot as plt

fig1 = figure()
fig2 = figure()
fig1 = plt.figure()
fig2 = plt.figure()

ax1 = fig1.add_subplot(111)
ax2 = fig2.add_subplot(111, sharex=ax1, sharey=ax1)

ax1.plot(numpy.random.rand(100), 'o')
ax2.plot(numpy.random.rand(100), 'o')
ax1.plot(np.random.rand(100), 'o')
ax2.plot(np.random.rand(100), 'o')

# In the latest release, it is no longer necessary to do anything
# special to share axes across figures:
Expand All @@ -25,4 +24,4 @@
# ax1.sharey_foreign(ax2)
# ax2.sharey_foreign(ax1)

show()
plt.show()
33 changes: 17 additions & 16 deletions 33 examples/pylab_examples/shared_axis_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,27 @@

setp( ax2.get_xticklabels(), visible=False)


"""
from pylab import *
import matplotlib.pyplot as plt
import numpy as np

t = np.arange(0.01, 5.0, 0.01)
s1 = np.sin(2*np.pi*t)
s2 = np.exp(-t)
s3 = np.sin(4*np.pi*t)

t = arange(0.01, 5.0, 0.01)
s1 = sin(2*pi*t)
s2 = exp(-t)
s3 = sin(4*pi*t)
ax1 = subplot(311)
plot(t, s1)
setp(ax1.get_xticklabels(), fontsize=6)
ax1 = plt.subplot(311)
plt.plot(t, s1)
plt.setp(ax1.get_xticklabels(), fontsize=6)

# share x only
ax2 = subplot(312, sharex=ax1)
plot(t, s2)
ax2 = plt.subplot(312, sharex=ax1)
plt.plot(t, s2)
# make these tick labels invisible
setp(ax2.get_xticklabels(), visible=False)
plt.setp(ax2.get_xticklabels(), visible=False)

# share x and y
ax3 = subplot(313, sharex=ax1, sharey=ax1)
plot(t, s3)
xlim(0.01, 5.0)
show()
ax3 = plt.subplot(313, sharex=ax1, sharey=ax1)
plt.plot(t, s3)
plt.xlim(0.01, 5.0)
plt.show()
21 changes: 11 additions & 10 deletions 21 examples/pylab_examples/simple_plot.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
from pylab import *
import matplotlib.pyplot as plt
import numpy as np

t = arange(0.0, 2.0, 0.01)
s = sin(2*pi*t)
plot(t, s)
t = np.arange(0.0, 2.0, 0.01)
s = np.sin(2*np.pi*t)
plt.plot(t, s)

xlabel('time (s)')
ylabel('voltage (mV)')
title('About as simple as it gets, folks')
grid(True)
savefig("test.png")
show()
plt.xlabel('time (s)')
plt.ylabel('voltage (mV)')
plt.title('About as simple as it gets, folks')
plt.grid(True)
plt.savefig("test.png")
plt.show()
28 changes: 13 additions & 15 deletions 28 examples/pylab_examples/simple_plot_fps.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,30 @@
#!/usr/bin/env python

"""
Example: simple line plot.
Show how to make and save a simple line plot with labels, title and grid
"""
# -*- noplot -*-
from __future__ import print_function
from pylab import *
from __future__ import print_function # not necessary in Python 3.x
import matplotlib.pyplot as plt
import numpy as np
import time

ion()

t = arange(0.0, 1.0 + 0.001, 0.001)
s = cos(2*2*pi*t)
plot(t, s, '-', lw=2)
plt.ion()

xlabel('time (s)')
ylabel('voltage (mV)')
title('About as simple as it gets, folks')
grid(True)
t = np.arange(0.0, 1.0 + 0.001, 0.001)
s = np.cos(2*2*np.pi*t)
plt.plot(t, s, '-', lw=2)

import time
plt.xlabel('time (s)')
plt.ylabel('voltage (mV)')
plt.title('About as simple as it gets, folks')
plt.grid(True)

frames = 100.0
t = time.time()
c = time.clock()
for i in range(int(frames)):
part = i / frames
axis([0.0, 1.0 - part, -1.0 + part, 1.0 - part])
plt.axis([0.0, 1.0 - part, -1.0 + part, 1.0 - part])
wallclock = time.time() - t
user = time.clock() - c
print("wallclock:", wallclock)
Expand Down
26 changes: 13 additions & 13 deletions 26 examples/pylab_examples/specgram_demo.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#!/usr/bin/env python
from pylab import *
import matplotlib.pyplot as plt
import numpy as np

dt = 0.0005
t = arange(0.0, 20.0, dt)
s1 = sin(2*pi*100*t)
s2 = 2*sin(2*pi*400*t)
t = np.arange(0.0, 20.0, dt)
s1 = np.sin(2*np.pi*100*t)
s2 = 2*np.sin(2*np.pi*400*t)

# create a transient "chirp"
mask = where(logical_and(t > 10, t < 12), 1.0, 0.0)
mask = np.where(np.logical_and(t > 10, t < 12), 1.0, 0.0)
s2 = s2 * mask

# add some noise into the mix
nse = 0.01*randn(len(t))
nse = 0.01*np.random.random(size=len(t))

x = s1 + s2 + nse # the signal
NFFT = 1024 # the length of the windowing segments
Expand All @@ -22,9 +22,9 @@
# the power is computed, and im is the matplotlib.image.AxesImage
# instance

ax1 = subplot(211)
plot(t, x)
subplot(212, sharex=ax1)
Pxx, freqs, bins, im = specgram(x, NFFT=NFFT, Fs=Fs, noverlap=900,
cmap=cm.gist_heat)
show()
ax1 = plt.subplot(211)
plt.plot(t, x)
plt.subplot(212, sharex=ax1)
Pxx, freqs, bins, im = plt.specgram(x, NFFT=NFFT, Fs=Fs, noverlap=900,
cmap=plt.cm.gist_heat)
plt.show()
38 changes: 18 additions & 20 deletions 38 examples/pylab_examples/spectrum_demo.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,29 @@
#!/usr/bin/env python
# python

from pylab import *
import matplotlib.pyplot as plt
import numpy as np

dt = 0.01
Fs = 1/dt
t = arange(0, 10, dt)
nse = randn(len(t))
r = exp(-t/0.05)
t = np.arange(0, 10, dt)
nse = np.random.randn(len(t))
r = np.exp(-t/0.05)

cnse = convolve(nse, r)*dt
cnse = np.convolve(nse, r)*dt
cnse = cnse[:len(t)]
s = 0.1*sin(2*pi*t) + cnse
s = 0.1*np.sin(2*np.pi*t) + cnse

subplot(3, 2, 1)
plot(t, s)
plt.subplot(3, 2, 1)
plt.plot(t, s)

subplot(3, 2, 3)
magnitude_spectrum(s, Fs=Fs)
plt.subplot(3, 2, 3)
plt.magnitude_spectrum(s, Fs=Fs)

subplot(3, 2, 4)
magnitude_spectrum(s, Fs=Fs, scale='dB')
plt.subplot(3, 2, 4)
plt.magnitude_spectrum(s, Fs=Fs, scale='dB')

subplot(3, 2, 5)
angle_spectrum(s, Fs=Fs)
plt.subplot(3, 2, 5)
plt.angle_spectrum(s, Fs=Fs)

subplot(3, 2, 6)
phase_spectrum(s, Fs=Fs)
plt.subplot(3, 2, 6)
plt.phase_spectrum(s, Fs=Fs)

show()
plt.show()
20 changes: 10 additions & 10 deletions 20 examples/pylab_examples/subplots_adjust.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from pylab import *
import matplotlib.pyplot as plt
import numpy as np

plt.subplot(211)
plt.imshow(np.random.random((100, 100)), cmap=plt.cm.BuPu_r)
plt.subplot(212)
plt.imshow(np.random.random((100, 100)), cmap=plt.cm.BuPu_r)

subplot(211)
imshow(rand(100, 100), cmap=cm.BuPu_r)
subplot(212)
imshow(rand(100, 100), cmap=cm.BuPu_r)

subplots_adjust(bottom=0.1, right=0.8, top=0.9)
cax = axes([0.85, 0.1, 0.075, 0.8])
colorbar(cax=cax)
show()
plt.subplots_adjust(bottom=0.1, right=0.8, top=0.9)
cax = plt.axes([0.85, 0.1, 0.075, 0.8])
plt.colorbar(cax=cax)
plt.show()
Morty Proxy This is a proxified and sanitized view of the page, visit original site.