def plot_eigenspectrum(G, s, nvis, nhid):
with misc.gnumpy_conversion_check('allow'):
dim = G.shape[0]
d, Q = scipy.linalg.eigh(G)
d = d[::-1]
Q = Q[:, ::-1]
pts = np.unique(np.floor(np.logspace(0., np.log10(dim-1), 500)).astype(int)) - 1
cf = [fisher.correlation_fraction(Q[:, i], s, nvis, nhid) for i in pts]
pylab.figure()
pylab.subplot(2, 1, 1)
pylab.loglog(range(1, dim+1), d, 'b-', lw=2.)
pylab.xticks([])
pylab.yticks(fontsize='large')
pylab.subplot(2, 1, 2)
pylab.semilogx(pts+1, cf, 'r-', lw=2.)
pylab.xticks(fontsize='x-large')
pylab.yticks(fontsize='large')
python类loglog()的实例源码
def ComputePer(self,beta):
"""
compute a periodigram for the data and compared it to a theorical line
"""
datafft=np.fft.fft(self.data)
per=np.abs(datafft)**2
py.plot(per)
x=np.array([100.*i+1 for i in range(self.length*self.res)])
y=per[0]*(1./x)**(beta/2)
py.loglog(x,y,c='red')
py.show()
def plot_responses(options, config, event_names):
import pylab as lab
conf = config['iris_pull_config']
if not event_names:
sys.exit('need event name')
for event_name in event_names:
conf.event_name = event_name
stations = _get_stations(conf)
event = _get_event_infos(conf)
fband = conf.inv_response_frequencyband
combi_get_responses(stations, event.time, conf.path('resp_path'))
for station in stations:
for cha in station.get_channels():
resp = cha.inv_response
fmin, fmax = fband[0], fband[3]
freqs = num.exp(num.linspace(num.log(fmin), num.log(fmax), 400))
amps = num.abs(resp.evaluate(freqs))
lab.loglog(freqs, amps)
lab.show()