-
Notifications
You must be signed in to change notification settings - Fork 60
Expand file tree
/
Copy pathmlab_api.html
More file actions
1827 lines (1688 loc) · 131 KB
/
mlab_api.html
File metadata and controls
1827 lines (1688 loc) · 131 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>mlab — Matplotlib 1.3.1 documentation</title>
<link rel="stylesheet" href="../_static/mpl.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '../',
VERSION: '1.3.1',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="../_static/jquery.js"></script>
<script type="text/javascript" src="../_static/underscore.js"></script>
<script type="text/javascript" src="../_static/doctools.js"></script>
<link rel="search" type="application/opensearchdescription+xml"
title="Search within Matplotlib 1.3.1 documentation"
href="../_static/opensearch.xml"/>
<link rel="top" title="Matplotlib 1.3.1 documentation" href="../index.html" />
<link rel="up" title="The Matplotlib API" href="index.html" />
<link rel="next" title="path" href="path_api.html" />
<link rel="prev" title="mathtext" href="mathtext_api.html" />
<link rel="canonical" href="https://matplotlib.org/stable/api/mlab_api.html" />
<script data-domain="matplotlib.org" defer="defer" src="https://views.scientific-python.org/js/script.js"></script>
</head>
<body>
<div id="unreleased-message"> You are reading an old version of the documentation (v1.3.1). For the latest version see <a href="https://matplotlib.org/stable/api/mlab_api.html">https://matplotlib.org/stable/api/mlab_api.html</a></div>
<!-- Piwik -->
<script type="text/javascript">
if ("matplotlib.sourceforge.net" == document.location.hostname ||
"matplotlib.sf.net" == document.location.hostname) {
var pkBaseURL = (("https:" == document.location.protocol) ? "https://apps.sourceforge.net/piwik/matplotlib/" : "http://apps.sourceforge.net/piwik/matplotlib/");
document.write(unescape("%3Cscript src='" + pkBaseURL + "piwik.js' type='text/javascript'%3E%3C/script%3E"));
}
</script>
<script type="text/javascript">
if ("matplotlib.sourceforge.net" == document.location.hostname ||
"matplotlib.sf.net" == document.location.hostname) {
piwik_action_name = '';
piwik_idsite = 1;
piwik_url = pkBaseURL + "piwik.php";
piwik_log(piwik_action_name, piwik_idsite, piwik_url);
document.write(unescape('%3Cobject%3E%3Cnoscript%3E%3Cp%3E%3Cimg src="http://apps.sourceforge.net/piwik/matplotlib/piwik.php?idsite=1" alt="piwik"/%3E%3C/p%3E%3C/noscript%3E%3C/object%3E'));
}
</script>
<!-- End Piwik Tag -->
<link rel="shortcut icon" href="_static/favicon.ico">
<!-- The "Fork me on github" ribbon -->
<img style="float: right; margin-bottom: -40px; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_orange_ff7600.png" usemap="#ribbonmap"/>
<map name="ribbonmap">
<area shape="poly" coords="15,0,148,-1,148,135" href="https://github.com/matplotlib/matplotlib" title="Fork me on GitHub" />
</map>
<div style="background-color: white; text-align: left; padding: 10px 10px 15px 15px">
<a href="../index.html"><img src="../_static/logo2.png" border="0" alt="matplotlib"/></a>
</div>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="path_api.html" title="path"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="mathtext_api.html" title="mathtext"
accesskey="P">previous</a> |</li>
<li><a href="../index.html">home</a>| </li>
<li><a href="../examples/index.html">examples</a>| </li>
<li><a href="../gallery.html">gallery</a>| </li>
<li><a href="pyplot_summary.html">pyplot</a>| </li>
<li><a href="../contents.html">docs</a> »</li>
<li><a href="index.html" accesskey="U">The Matplotlib API</a> »</li>
</ul>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<h3><a href="../contents.html">Table Of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">mlab</a><ul>
<li><a class="reference internal" href="#module-matplotlib.mlab"><tt class="docutils literal"><span class="pre">matplotlib.mlab</span></tt></a><ul>
<li><a class="reference internal" href="#matlab-compatible-functions">MATLAB compatible functions</a></li>
<li><a class="reference internal" href="#miscellaneous-functions">Miscellaneous functions</a></li>
<li><a class="reference internal" href="#record-array-helper-functions">record array helper functions</a></li>
<li><a class="reference internal" href="#deprecated-functions">Deprecated functions</a></li>
</ul>
</li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="mathtext_api.html"
title="previous chapter">mathtext</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="path_api.html"
title="next chapter">path</a></p>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="../_sources/api/mlab_api.txt"
rel="nofollow">Show Source</a></li>
</ul>
<div id="searchbox" style="display: none">
<h3>Quick search</h3>
<form class="search" action="../search.html" method="get">
<input type="text" name="q" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<div class="section" id="mlab">
<h1>mlab<a class="headerlink" href="#mlab" title="Permalink to this headline">¶</a></h1>
<div class="section" id="module-matplotlib.mlab">
<span id="matplotlib-mlab"></span><h2><a class="reference internal" href="#module-matplotlib.mlab" title="matplotlib.mlab"><tt class="xref py py-mod docutils literal"><span class="pre">matplotlib.mlab</span></tt></a><a class="headerlink" href="#module-matplotlib.mlab" title="Permalink to this headline">¶</a></h2>
<p>Numerical python functions written for compatability with MATLAB
commands with the same names.</p>
<div class="section" id="matlab-compatible-functions">
<h3>MATLAB compatible functions<a class="headerlink" href="#matlab-compatible-functions" title="Permalink to this headline">¶</a></h3>
<dl class="docutils">
<dt><a class="reference internal" href="#matplotlib.mlab.cohere" title="matplotlib.mlab.cohere"><tt class="xref py py-func docutils literal"><span class="pre">cohere()</span></tt></a></dt>
<dd>Coherence (normalized cross spectral density)</dd>
<dt><a class="reference internal" href="#matplotlib.mlab.csd" title="matplotlib.mlab.csd"><tt class="xref py py-func docutils literal"><span class="pre">csd()</span></tt></a></dt>
<dd>Cross spectral density uing Welch’s average periodogram</dd>
<dt><a class="reference internal" href="#matplotlib.mlab.detrend" title="matplotlib.mlab.detrend"><tt class="xref py py-func docutils literal"><span class="pre">detrend()</span></tt></a></dt>
<dd>Remove the mean or best fit line from an array</dd>
<dt><a class="reference internal" href="#matplotlib.mlab.find" title="matplotlib.mlab.find"><tt class="xref py py-func docutils literal"><span class="pre">find()</span></tt></a></dt>
<dd><dl class="first last docutils">
<dt>Return the indices where some condition is true;</dt>
<dd>numpy.nonzero is similar but more general.</dd>
</dl>
</dd>
<dt><a class="reference internal" href="#matplotlib.mlab.griddata" title="matplotlib.mlab.griddata"><tt class="xref py py-func docutils literal"><span class="pre">griddata()</span></tt></a></dt>
<dd><dl class="first last docutils">
<dt>interpolate irregularly distributed data to a</dt>
<dd>regular grid.</dd>
</dl>
</dd>
<dt><a class="reference internal" href="#matplotlib.mlab.prctile" title="matplotlib.mlab.prctile"><tt class="xref py py-func docutils literal"><span class="pre">prctile()</span></tt></a></dt>
<dd>find the percentiles of a sequence</dd>
<dt><a class="reference internal" href="#matplotlib.mlab.prepca" title="matplotlib.mlab.prepca"><tt class="xref py py-func docutils literal"><span class="pre">prepca()</span></tt></a></dt>
<dd>Principal Component Analysis</dd>
<dt><a class="reference internal" href="#matplotlib.mlab.psd" title="matplotlib.mlab.psd"><tt class="xref py py-func docutils literal"><span class="pre">psd()</span></tt></a></dt>
<dd>Power spectral density uing Welch’s average periodogram</dd>
<dt><a class="reference internal" href="#matplotlib.mlab.rk4" title="matplotlib.mlab.rk4"><tt class="xref py py-func docutils literal"><span class="pre">rk4()</span></tt></a></dt>
<dd>A 4th order runge kutta integrator for 1D or ND systems</dd>
<dt><a class="reference internal" href="#matplotlib.mlab.specgram" title="matplotlib.mlab.specgram"><tt class="xref py py-func docutils literal"><span class="pre">specgram()</span></tt></a></dt>
<dd>Spectrogram (power spectral density over segments of time)</dd>
</dl>
</div>
<div class="section" id="miscellaneous-functions">
<h3>Miscellaneous functions<a class="headerlink" href="#miscellaneous-functions" title="Permalink to this headline">¶</a></h3>
<p>Functions that don’t exist in MATLAB, but are useful anyway:</p>
<dl class="docutils">
<dt><a class="reference internal" href="#matplotlib.mlab.cohere_pairs" title="matplotlib.mlab.cohere_pairs"><tt class="xref py py-meth docutils literal"><span class="pre">cohere_pairs()</span></tt></a></dt>
<dd>Coherence over all pairs. This is not a MATLAB function, but we
compute coherence a lot in my lab, and we compute it for a lot of
pairs. This function is optimized to do this efficiently by
caching the direct FFTs.</dd>
<dt><a class="reference internal" href="#matplotlib.mlab.rk4" title="matplotlib.mlab.rk4"><tt class="xref py py-meth docutils literal"><span class="pre">rk4()</span></tt></a></dt>
<dd>A 4th order Runge-Kutta ODE integrator in case you ever find
yourself stranded without scipy (and the far superior
scipy.integrate tools)</dd>
<dt><a class="reference internal" href="#matplotlib.mlab.contiguous_regions" title="matplotlib.mlab.contiguous_regions"><tt class="xref py py-meth docutils literal"><span class="pre">contiguous_regions()</span></tt></a></dt>
<dd>return the indices of the regions spanned by some logical mask</dd>
<dt><a class="reference internal" href="#matplotlib.mlab.cross_from_below" title="matplotlib.mlab.cross_from_below"><tt class="xref py py-meth docutils literal"><span class="pre">cross_from_below()</span></tt></a></dt>
<dd>return the indices where a 1D array crosses a threshold from below</dd>
<dt><a class="reference internal" href="#matplotlib.mlab.cross_from_above" title="matplotlib.mlab.cross_from_above"><tt class="xref py py-meth docutils literal"><span class="pre">cross_from_above()</span></tt></a></dt>
<dd>return the indices where a 1D array crosses a threshold from above</dd>
</dl>
</div>
<div class="section" id="record-array-helper-functions">
<h3>record array helper functions<a class="headerlink" href="#record-array-helper-functions" title="Permalink to this headline">¶</a></h3>
<p>A collection of helper methods for numpyrecord arrays</p>
<blockquote id="htmlonly">
<div>See <a class="reference internal" href="../examples/misc/index.html#misc-examples-index"><em>misc Examples</em></a></div></blockquote>
<dl class="docutils">
<dt><a class="reference internal" href="#matplotlib.mlab.rec2txt" title="matplotlib.mlab.rec2txt"><tt class="xref py py-meth docutils literal"><span class="pre">rec2txt()</span></tt></a></dt>
<dd>pretty print a record array</dd>
<dt><a class="reference internal" href="#matplotlib.mlab.rec2csv" title="matplotlib.mlab.rec2csv"><tt class="xref py py-meth docutils literal"><span class="pre">rec2csv()</span></tt></a></dt>
<dd>store record array in CSV file</dd>
<dt><a class="reference internal" href="#matplotlib.mlab.csv2rec" title="matplotlib.mlab.csv2rec"><tt class="xref py py-meth docutils literal"><span class="pre">csv2rec()</span></tt></a></dt>
<dd>import record array from CSV file with type inspection</dd>
<dt><a class="reference internal" href="#matplotlib.mlab.rec_append_fields" title="matplotlib.mlab.rec_append_fields"><tt class="xref py py-meth docutils literal"><span class="pre">rec_append_fields()</span></tt></a></dt>
<dd>adds field(s)/array(s) to record array</dd>
<dt><a class="reference internal" href="#matplotlib.mlab.rec_drop_fields" title="matplotlib.mlab.rec_drop_fields"><tt class="xref py py-meth docutils literal"><span class="pre">rec_drop_fields()</span></tt></a></dt>
<dd>drop fields from record array</dd>
<dt><a class="reference internal" href="#matplotlib.mlab.rec_join" title="matplotlib.mlab.rec_join"><tt class="xref py py-meth docutils literal"><span class="pre">rec_join()</span></tt></a></dt>
<dd>join two record arrays on sequence of fields</dd>
<dt><a class="reference internal" href="#matplotlib.mlab.recs_join" title="matplotlib.mlab.recs_join"><tt class="xref py py-meth docutils literal"><span class="pre">recs_join()</span></tt></a></dt>
<dd>a simple join of multiple recarrays using a single column as a key</dd>
<dt><a class="reference internal" href="#matplotlib.mlab.rec_groupby" title="matplotlib.mlab.rec_groupby"><tt class="xref py py-meth docutils literal"><span class="pre">rec_groupby()</span></tt></a></dt>
<dd>summarize data by groups (similar to SQL GROUP BY)</dd>
<dt><a class="reference internal" href="#matplotlib.mlab.rec_summarize" title="matplotlib.mlab.rec_summarize"><tt class="xref py py-meth docutils literal"><span class="pre">rec_summarize()</span></tt></a></dt>
<dd>helper code to filter rec array fields into new fields</dd>
</dl>
<p>For the rec viewer functions(e rec2csv), there are a bunch of Format
objects you can pass into the functions that will do things like color
negative values red, set percent formatting and scaling, etc.</p>
<p>Example usage:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">r</span> <span class="o">=</span> <span class="n">csv2rec</span><span class="p">(</span><span class="s">'somefile.csv'</span><span class="p">,</span> <span class="n">checkrows</span><span class="o">=</span><span class="mi">0</span><span class="p">)</span>
<span class="n">formatd</span> <span class="o">=</span> <span class="nb">dict</span><span class="p">(</span>
<span class="n">weight</span> <span class="o">=</span> <span class="n">FormatFloat</span><span class="p">(</span><span class="mi">2</span><span class="p">),</span>
<span class="n">change</span> <span class="o">=</span> <span class="n">FormatPercent</span><span class="p">(</span><span class="mi">2</span><span class="p">),</span>
<span class="n">cost</span> <span class="o">=</span> <span class="n">FormatThousands</span><span class="p">(</span><span class="mi">2</span><span class="p">),</span>
<span class="p">)</span>
<span class="n">rec2excel</span><span class="p">(</span><span class="n">r</span><span class="p">,</span> <span class="s">'test.xls'</span><span class="p">,</span> <span class="n">formatd</span><span class="o">=</span><span class="n">formatd</span><span class="p">)</span>
<span class="n">rec2csv</span><span class="p">(</span><span class="n">r</span><span class="p">,</span> <span class="s">'test.csv'</span><span class="p">,</span> <span class="n">formatd</span><span class="o">=</span><span class="n">formatd</span><span class="p">)</span>
<span class="n">scroll</span> <span class="o">=</span> <span class="n">rec2gtk</span><span class="p">(</span><span class="n">r</span><span class="p">,</span> <span class="n">formatd</span><span class="o">=</span><span class="n">formatd</span><span class="p">)</span>
<span class="n">win</span> <span class="o">=</span> <span class="n">gtk</span><span class="o">.</span><span class="n">Window</span><span class="p">()</span>
<span class="n">win</span><span class="o">.</span><span class="n">set_size_request</span><span class="p">(</span><span class="mi">600</span><span class="p">,</span><span class="mi">800</span><span class="p">)</span>
<span class="n">win</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">scroll</span><span class="p">)</span>
<span class="n">win</span><span class="o">.</span><span class="n">show_all</span><span class="p">()</span>
<span class="n">gtk</span><span class="o">.</span><span class="n">main</span><span class="p">()</span>
</pre></div>
</div>
</div>
<div class="section" id="deprecated-functions">
<h3>Deprecated functions<a class="headerlink" href="#deprecated-functions" title="Permalink to this headline">¶</a></h3>
<p>The following are deprecated; please import directly from numpy (with
care–function signatures may differ):</p>
<dl class="docutils">
<dt><tt class="xref py py-meth docutils literal"><span class="pre">load()</span></tt></dt>
<dd>load ASCII file - use numpy.loadtxt</dd>
<dt><tt class="xref py py-meth docutils literal"><span class="pre">save()</span></tt></dt>
<dd>save ASCII file - use numpy.savetxt</dd>
</dl>
<dl class="class">
<dt id="matplotlib.mlab.FIFOBuffer">
<em class="property">class </em><tt class="descclassname">matplotlib.mlab.</tt><tt class="descname">FIFOBuffer</tt><big>(</big><em>*args</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#matplotlib.mlab.FIFOBuffer" title="Permalink to this definition">¶</a></dt>
<dd><p>A FIFO queue to hold incoming <em>x</em>, <em>y</em> data in a rotating buffer
using numpy arrays under the hood. It is assumed that you will
call asarrays much less frequently than you add data to the queue
– otherwise another data structure will be faster.</p>
<p>This can be used to support plots where data is added from a real
time feed and the plot object wants to grab data from the buffer
and plot it to screen less freqeuently than the incoming.</p>
<p>If you set the <em>dataLim</em> attr to
<tt class="xref py py-class docutils literal"><span class="pre">BBox</span></tt> (eg
<tt class="xref py py-attr docutils literal"><span class="pre">matplotlib.Axes.dataLim</span></tt>), the <em>dataLim</em> will be updated as
new data come in.</p>
<p>TODO: add a grow method that will extend nmax</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">mlab seems like the wrong place for this class.</p>
</div>
<div class="deprecated">
<p><span>Deprecated since version 1.3: </span>The FIFOBuffer class was deprecated in version 1.3.</p>
</div>
<p>Buffer up to <em>nmax</em> points.</p>
<dl class="method">
<dt id="matplotlib.mlab.FIFOBuffer.add">
<tt class="descname">add</tt><big>(</big><em>x</em>, <em>y</em><big>)</big><a class="headerlink" href="#matplotlib.mlab.FIFOBuffer.add" title="Permalink to this definition">¶</a></dt>
<dd><p>Add scalar <em>x</em> and <em>y</em> to the queue.</p>
</dd></dl>
<dl class="method">
<dt id="matplotlib.mlab.FIFOBuffer.asarrays">
<tt class="descname">asarrays</tt><big>(</big><big>)</big><a class="headerlink" href="#matplotlib.mlab.FIFOBuffer.asarrays" title="Permalink to this definition">¶</a></dt>
<dd><p>Return <em>x</em> and <em>y</em> as arrays; their length will be the len of
data added or <em>nmax</em>.</p>
</dd></dl>
<dl class="method">
<dt id="matplotlib.mlab.FIFOBuffer.last">
<tt class="descname">last</tt><big>(</big><big>)</big><a class="headerlink" href="#matplotlib.mlab.FIFOBuffer.last" title="Permalink to this definition">¶</a></dt>
<dd><p>Get the last <em>x</em>, <em>y</em> or <em>None</em>. <em>None</em> if no data set.</p>
</dd></dl>
<dl class="method">
<dt id="matplotlib.mlab.FIFOBuffer.register">
<tt class="descname">register</tt><big>(</big><em>func</em>, <em>N</em><big>)</big><a class="headerlink" href="#matplotlib.mlab.FIFOBuffer.register" title="Permalink to this definition">¶</a></dt>
<dd><p>Call <em>func</em> every time <em>N</em> events are passed; <em>func</em> signature
is <tt class="docutils literal"><span class="pre">func(fifo)</span></tt>.</p>
</dd></dl>
<dl class="method">
<dt id="matplotlib.mlab.FIFOBuffer.update_datalim_to_current">
<tt class="descname">update_datalim_to_current</tt><big>(</big><big>)</big><a class="headerlink" href="#matplotlib.mlab.FIFOBuffer.update_datalim_to_current" title="Permalink to this definition">¶</a></dt>
<dd><p>Update the <em>datalim</em> in the current data in the fifo.</p>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="matplotlib.mlab.FormatBool">
<em class="property">class </em><tt class="descclassname">matplotlib.mlab.</tt><tt class="descname">FormatBool</tt><a class="headerlink" href="#matplotlib.mlab.FormatBool" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#matplotlib.mlab.FormatObj" title="matplotlib.mlab.FormatObj"><tt class="xref py py-class docutils literal"><span class="pre">matplotlib.mlab.FormatObj</span></tt></a></p>
<dl class="method">
<dt id="matplotlib.mlab.FormatBool.fromstr">
<tt class="descname">fromstr</tt><big>(</big><em>s</em><big>)</big><a class="headerlink" href="#matplotlib.mlab.FormatBool.fromstr" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="matplotlib.mlab.FormatBool.toval">
<tt class="descname">toval</tt><big>(</big><em>x</em><big>)</big><a class="headerlink" href="#matplotlib.mlab.FormatBool.toval" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
</dd></dl>
<dl class="class">
<dt id="matplotlib.mlab.FormatDate">
<em class="property">class </em><tt class="descclassname">matplotlib.mlab.</tt><tt class="descname">FormatDate</tt><big>(</big><em>fmt</em><big>)</big><a class="headerlink" href="#matplotlib.mlab.FormatDate" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#matplotlib.mlab.FormatObj" title="matplotlib.mlab.FormatObj"><tt class="xref py py-class docutils literal"><span class="pre">matplotlib.mlab.FormatObj</span></tt></a></p>
<dl class="method">
<dt id="matplotlib.mlab.FormatDate.fromstr">
<tt class="descname">fromstr</tt><big>(</big><em>x</em><big>)</big><a class="headerlink" href="#matplotlib.mlab.FormatDate.fromstr" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="matplotlib.mlab.FormatDate.toval">
<tt class="descname">toval</tt><big>(</big><em>x</em><big>)</big><a class="headerlink" href="#matplotlib.mlab.FormatDate.toval" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
</dd></dl>
<dl class="class">
<dt id="matplotlib.mlab.FormatDatetime">
<em class="property">class </em><tt class="descclassname">matplotlib.mlab.</tt><tt class="descname">FormatDatetime</tt><big>(</big><em>fmt='%Y-%m-%d %H:%M:%S'</em><big>)</big><a class="headerlink" href="#matplotlib.mlab.FormatDatetime" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#matplotlib.mlab.FormatDate" title="matplotlib.mlab.FormatDate"><tt class="xref py py-class docutils literal"><span class="pre">matplotlib.mlab.FormatDate</span></tt></a></p>
<dl class="method">
<dt id="matplotlib.mlab.FormatDatetime.fromstr">
<tt class="descname">fromstr</tt><big>(</big><em>x</em><big>)</big><a class="headerlink" href="#matplotlib.mlab.FormatDatetime.fromstr" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
</dd></dl>
<dl class="class">
<dt id="matplotlib.mlab.FormatFloat">
<em class="property">class </em><tt class="descclassname">matplotlib.mlab.</tt><tt class="descname">FormatFloat</tt><big>(</big><em>precision=4</em>, <em>scale=1.0</em><big>)</big><a class="headerlink" href="#matplotlib.mlab.FormatFloat" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#matplotlib.mlab.FormatFormatStr" title="matplotlib.mlab.FormatFormatStr"><tt class="xref py py-class docutils literal"><span class="pre">matplotlib.mlab.FormatFormatStr</span></tt></a></p>
<dl class="method">
<dt id="matplotlib.mlab.FormatFloat.fromstr">
<tt class="descname">fromstr</tt><big>(</big><em>s</em><big>)</big><a class="headerlink" href="#matplotlib.mlab.FormatFloat.fromstr" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="matplotlib.mlab.FormatFloat.toval">
<tt class="descname">toval</tt><big>(</big><em>x</em><big>)</big><a class="headerlink" href="#matplotlib.mlab.FormatFloat.toval" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
</dd></dl>
<dl class="class">
<dt id="matplotlib.mlab.FormatFormatStr">
<em class="property">class </em><tt class="descclassname">matplotlib.mlab.</tt><tt class="descname">FormatFormatStr</tt><big>(</big><em>fmt</em><big>)</big><a class="headerlink" href="#matplotlib.mlab.FormatFormatStr" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#matplotlib.mlab.FormatObj" title="matplotlib.mlab.FormatObj"><tt class="xref py py-class docutils literal"><span class="pre">matplotlib.mlab.FormatObj</span></tt></a></p>
<dl class="method">
<dt id="matplotlib.mlab.FormatFormatStr.tostr">
<tt class="descname">tostr</tt><big>(</big><em>x</em><big>)</big><a class="headerlink" href="#matplotlib.mlab.FormatFormatStr.tostr" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
</dd></dl>
<dl class="class">
<dt id="matplotlib.mlab.FormatInt">
<em class="property">class </em><tt class="descclassname">matplotlib.mlab.</tt><tt class="descname">FormatInt</tt><a class="headerlink" href="#matplotlib.mlab.FormatInt" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#matplotlib.mlab.FormatObj" title="matplotlib.mlab.FormatObj"><tt class="xref py py-class docutils literal"><span class="pre">matplotlib.mlab.FormatObj</span></tt></a></p>
<dl class="method">
<dt id="matplotlib.mlab.FormatInt.fromstr">
<tt class="descname">fromstr</tt><big>(</big><em>s</em><big>)</big><a class="headerlink" href="#matplotlib.mlab.FormatInt.fromstr" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="matplotlib.mlab.FormatInt.tostr">
<tt class="descname">tostr</tt><big>(</big><em>x</em><big>)</big><a class="headerlink" href="#matplotlib.mlab.FormatInt.tostr" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="matplotlib.mlab.FormatInt.toval">
<tt class="descname">toval</tt><big>(</big><em>x</em><big>)</big><a class="headerlink" href="#matplotlib.mlab.FormatInt.toval" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
</dd></dl>
<dl class="class">
<dt id="matplotlib.mlab.FormatMillions">
<em class="property">class </em><tt class="descclassname">matplotlib.mlab.</tt><tt class="descname">FormatMillions</tt><big>(</big><em>precision=4</em><big>)</big><a class="headerlink" href="#matplotlib.mlab.FormatMillions" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#matplotlib.mlab.FormatFloat" title="matplotlib.mlab.FormatFloat"><tt class="xref py py-class docutils literal"><span class="pre">matplotlib.mlab.FormatFloat</span></tt></a></p>
</dd></dl>
<dl class="class">
<dt id="matplotlib.mlab.FormatObj">
<em class="property">class </em><tt class="descclassname">matplotlib.mlab.</tt><tt class="descname">FormatObj</tt><a class="headerlink" href="#matplotlib.mlab.FormatObj" title="Permalink to this definition">¶</a></dt>
<dd><dl class="method">
<dt id="matplotlib.mlab.FormatObj.fromstr">
<tt class="descname">fromstr</tt><big>(</big><em>s</em><big>)</big><a class="headerlink" href="#matplotlib.mlab.FormatObj.fromstr" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="matplotlib.mlab.FormatObj.tostr">
<tt class="descname">tostr</tt><big>(</big><em>x</em><big>)</big><a class="headerlink" href="#matplotlib.mlab.FormatObj.tostr" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="matplotlib.mlab.FormatObj.toval">
<tt class="descname">toval</tt><big>(</big><em>x</em><big>)</big><a class="headerlink" href="#matplotlib.mlab.FormatObj.toval" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
</dd></dl>
<dl class="class">
<dt id="matplotlib.mlab.FormatPercent">
<em class="property">class </em><tt class="descclassname">matplotlib.mlab.</tt><tt class="descname">FormatPercent</tt><big>(</big><em>precision=4</em><big>)</big><a class="headerlink" href="#matplotlib.mlab.FormatPercent" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#matplotlib.mlab.FormatFloat" title="matplotlib.mlab.FormatFloat"><tt class="xref py py-class docutils literal"><span class="pre">matplotlib.mlab.FormatFloat</span></tt></a></p>
</dd></dl>
<dl class="class">
<dt id="matplotlib.mlab.FormatString">
<em class="property">class </em><tt class="descclassname">matplotlib.mlab.</tt><tt class="descname">FormatString</tt><a class="headerlink" href="#matplotlib.mlab.FormatString" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#matplotlib.mlab.FormatObj" title="matplotlib.mlab.FormatObj"><tt class="xref py py-class docutils literal"><span class="pre">matplotlib.mlab.FormatObj</span></tt></a></p>
<dl class="method">
<dt id="matplotlib.mlab.FormatString.tostr">
<tt class="descname">tostr</tt><big>(</big><em>x</em><big>)</big><a class="headerlink" href="#matplotlib.mlab.FormatString.tostr" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
</dd></dl>
<dl class="class">
<dt id="matplotlib.mlab.FormatThousands">
<em class="property">class </em><tt class="descclassname">matplotlib.mlab.</tt><tt class="descname">FormatThousands</tt><big>(</big><em>precision=4</em><big>)</big><a class="headerlink" href="#matplotlib.mlab.FormatThousands" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#matplotlib.mlab.FormatFloat" title="matplotlib.mlab.FormatFloat"><tt class="xref py py-class docutils literal"><span class="pre">matplotlib.mlab.FormatFloat</span></tt></a></p>
</dd></dl>
<dl class="class">
<dt id="matplotlib.mlab.PCA">
<em class="property">class </em><tt class="descclassname">matplotlib.mlab.</tt><tt class="descname">PCA</tt><big>(</big><em>a</em><big>)</big><a class="headerlink" href="#matplotlib.mlab.PCA" title="Permalink to this definition">¶</a></dt>
<dd><p>compute the SVD of a and store data for PCA. Use project to
project the data onto a reduced set of dimensions</p>
<p>Inputs:</p>
<blockquote>
<div><em>a</em>: a numobservations x numdims array</div></blockquote>
<p>Attrs:</p>
<blockquote>
<div><p><em>a</em> a centered unit sigma version of input a</p>
<p><em>numrows</em>, <em>numcols</em>: the dimensions of a</p>
<p><em>mu</em> : a numdims array of means of a</p>
<p><em>sigma</em> : a numdims array of atandard deviation of a</p>
<p><em>fracs</em> : the proportion of variance of each of the principal components</p>
<p><em>Wt</em> : the weight vector for projecting a numdims point or array into PCA space</p>
<p><em>Y</em> : a projected into PCA space</p>
</div></blockquote>
<p>The factor loadings are in the Wt factor, ie the factor
loadings for the 1st principal component are given by Wt[0]</p>
<dl class="method">
<dt id="matplotlib.mlab.PCA.center">
<tt class="descname">center</tt><big>(</big><em>x</em><big>)</big><a class="headerlink" href="#matplotlib.mlab.PCA.center" title="Permalink to this definition">¶</a></dt>
<dd><p>center the data using the mean and sigma from training set a</p>
</dd></dl>
<dl class="method">
<dt id="matplotlib.mlab.PCA.project">
<tt class="descname">project</tt><big>(</big><em>x</em>, <em>minfrac=0.0</em><big>)</big><a class="headerlink" href="#matplotlib.mlab.PCA.project" title="Permalink to this definition">¶</a></dt>
<dd><p>project x onto the principle axes, dropping any axes where fraction of variance<minfrac</p>
</dd></dl>
</dd></dl>
<dl class="function">
<dt id="matplotlib.mlab.amap">
<tt class="descclassname">matplotlib.mlab.</tt><tt class="descname">amap</tt><big>(</big><em>function</em>, <em>sequence</em><span class="optional">[</span>, <em>sequence</em>, <em>...</em><span class="optional">]</span><big>)</big> → array.<a class="headerlink" href="#matplotlib.mlab.amap" title="Permalink to this definition">¶</a></dt>
<dd><p>Works like <tt class="xref py py-func docutils literal"><span class="pre">map()</span></tt>, but it returns an array. This is just a
convenient shorthand for <tt class="docutils literal"><span class="pre">numpy.array(map(...))</span></tt>.</p>
</dd></dl>
<dl class="function">
<dt id="matplotlib.mlab.base_repr">
<tt class="descclassname">matplotlib.mlab.</tt><tt class="descname">base_repr</tt><big>(</big><em>number</em>, <em>base=2</em>, <em>padding=0</em><big>)</big><a class="headerlink" href="#matplotlib.mlab.base_repr" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the representation of a <em>number</em> in any given <em>base</em>.</p>
</dd></dl>
<dl class="function">
<dt id="matplotlib.mlab.binary_repr">
<tt class="descclassname">matplotlib.mlab.</tt><tt class="descname">binary_repr</tt><big>(</big><em>number</em>, <em>max_length=1025</em><big>)</big><a class="headerlink" href="#matplotlib.mlab.binary_repr" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the binary representation of the input <em>number</em> as a
string.</p>
<p>This is more efficient than using <a class="reference internal" href="#matplotlib.mlab.base_repr" title="matplotlib.mlab.base_repr"><tt class="xref py py-func docutils literal"><span class="pre">base_repr()</span></tt></a> with base 2.</p>
<p>Increase the value of max_length for very large numbers. Note that
on 32-bit machines, 2**1023 is the largest integer power of 2
which can be converted to a Python float.</p>
</dd></dl>
<dl class="function">
<dt id="matplotlib.mlab.bivariate_normal">
<tt class="descclassname">matplotlib.mlab.</tt><tt class="descname">bivariate_normal</tt><big>(</big><em>X</em>, <em>Y</em>, <em>sigmax=1.0</em>, <em>sigmay=1.0</em>, <em>mux=0.0</em>, <em>muy=0.0</em>, <em>sigmaxy=0.0</em><big>)</big><a class="headerlink" href="#matplotlib.mlab.bivariate_normal" title="Permalink to this definition">¶</a></dt>
<dd><p>Bivariate Gaussian distribution for equal shape <em>X</em>, <em>Y</em>.</p>
<p>See <a class="reference external" href="http://mathworld.wolfram.com/BivariateNormalDistribution.html">bivariate normal</a>
at mathworld.</p>
</dd></dl>
<dl class="function">
<dt id="matplotlib.mlab.center_matrix">
<tt class="descclassname">matplotlib.mlab.</tt><tt class="descname">center_matrix</tt><big>(</big><em>M</em>, <em>dim=0</em><big>)</big><a class="headerlink" href="#matplotlib.mlab.center_matrix" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the matrix <em>M</em> with each row having zero mean and unit std.</p>
<p>If <em>dim</em> = 1 operate on columns instead of rows. (<em>dim</em> is
opposite to the numpy axis kwarg.)</p>
</dd></dl>
<dl class="function">
<dt id="matplotlib.mlab.cohere">
<tt class="descclassname">matplotlib.mlab.</tt><tt class="descname">cohere</tt><big>(</big><em>x</em>, <em>y</em>, <em>NFFT=256</em>, <em>Fs=2</em>, <em>detrend=<function detrend_none at 0x2635de8></em>, <em>window=<function window_hanning at 0x2635b90></em>, <em>noverlap=0</em>, <em>pad_to=None</em>, <em>sides='default'</em>, <em>scale_by_freq=None</em><big>)</big><a class="headerlink" href="#matplotlib.mlab.cohere" title="Permalink to this definition">¶</a></dt>
<dd><p>The coherence between <em>x</em> and <em>y</em>. Coherence is the normalized
cross spectral density:</p>
<img src="../_images/mathmpl/math-58775d54bf.png" class="center" /><dl class="docutils">
<dt><em>x</em>, <em>y</em></dt>
<dd>Array or sequence containing the data</dd>
</dl>
<p>Keyword arguments:</p>
<blockquote>
<div><dl class="docutils">
<dt><em>NFFT</em>: integer</dt>
<dd>The number of data points used in each block for the FFT.
Must be even; a power 2 is most efficient. The default value is 256.
This should <em>NOT</em> be used to get zero padding, or the scaling of the
result will be incorrect. Use <em>pad_to</em> for this instead.</dd>
<dt><em>Fs</em>: scalar</dt>
<dd>The sampling frequency (samples per time unit). It is used
to calculate the Fourier frequencies, freqs, in cycles per time
unit. The default value is 2.</dd>
<dt><em>detrend</em>: callable</dt>
<dd>The function applied to each segment before fft-ing,
designed to remove the mean or linear trend. Unlike in
MATLAB, where the <em>detrend</em> parameter is a vector, in
matplotlib is it a function. The <tt class="xref py py-mod docutils literal"><span class="pre">pylab</span></tt>
module defines <tt class="xref py py-func docutils literal"><span class="pre">detrend_none()</span></tt>,
<tt class="xref py py-func docutils literal"><span class="pre">detrend_mean()</span></tt>, and
<tt class="xref py py-func docutils literal"><span class="pre">detrend_linear()</span></tt>, but you can use
a custom function as well.</dd>
<dt><em>window</em>: callable or ndarray</dt>
<dd>A function or a vector of length <em>NFFT</em>. To create window
vectors see <a class="reference internal" href="#matplotlib.mlab.window_hanning" title="matplotlib.mlab.window_hanning"><tt class="xref py py-func docutils literal"><span class="pre">window_hanning()</span></tt></a>, <a class="reference internal" href="#matplotlib.mlab.window_none" title="matplotlib.mlab.window_none"><tt class="xref py py-func docutils literal"><span class="pre">window_none()</span></tt></a>,
<tt class="xref py py-func docutils literal"><span class="pre">numpy.blackman()</span></tt>, <tt class="xref py py-func docutils literal"><span class="pre">numpy.hamming()</span></tt>,
<tt class="xref py py-func docutils literal"><span class="pre">numpy.bartlett()</span></tt>, <tt class="xref py py-func docutils literal"><span class="pre">scipy.signal()</span></tt>,
<tt class="xref py py-func docutils literal"><span class="pre">scipy.signal.get_window()</span></tt>, etc. The default is
<a class="reference internal" href="#matplotlib.mlab.window_hanning" title="matplotlib.mlab.window_hanning"><tt class="xref py py-func docutils literal"><span class="pre">window_hanning()</span></tt></a>. If a function is passed as the
argument, it must take a data segment as an argument and
return the windowed version of the segment.</dd>
<dt><em>pad_to</em>: integer</dt>
<dd>The number of points to which the data segment is padded when
performing the FFT. This can be different from <em>NFFT</em>, which
specifies the number of data points used. While not increasing
the actual resolution of the psd (the minimum distance between
resolvable peaks), this can give more points in the plot,
allowing for more detail. This corresponds to the <em>n</em> parameter
in the call to fft(). The default is None, which sets <em>pad_to</em>
equal to <em>NFFT</em></dd>
<dt><em>sides</em>: [ ‘default’ | ‘onesided’ | ‘twosided’ ]</dt>
<dd>Specifies which sides of the PSD to return. Default gives the
default behavior, which returns one-sided for real data and both
for complex data. ‘onesided’ forces the return of a one-sided PSD,
while ‘twosided’ forces two-sided.</dd>
<dt><em>scale_by_freq</em>: boolean</dt>
<dd>Specifies whether the resulting density values should be scaled
by the scaling frequency, which gives density in units of Hz^-1.
This allows for integration over the returned frequency values.
The default is True for MATLAB compatibility.</dd>
<dt><em>noverlap</em>: integer</dt>
<dd>The number of points of overlap between blocks. The default value
is 0 (no overlap).</dd>
</dl>
</div></blockquote>
<p>The return value is the tuple (<em>Cxy</em>, <em>f</em>), where <em>f</em> are the
frequencies of the coherence vector. For cohere, scaling the
individual densities by the sampling frequency has no effect,
since the factors cancel out.</p>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<dl class="last docutils">
<dt><a class="reference internal" href="#matplotlib.mlab.psd" title="matplotlib.mlab.psd"><tt class="xref py py-func docutils literal"><span class="pre">psd()</span></tt></a> and <a class="reference internal" href="#matplotlib.mlab.csd" title="matplotlib.mlab.csd"><tt class="xref py py-func docutils literal"><span class="pre">csd()</span></tt></a></dt>
<dd>For information about the methods used to compute
<img src="../_images/mathmpl/math-0005c3a5e5.png" style="position: relative; bottom: -10px"/>, <img src="../_images/mathmpl/math-f6d65b7f49.png" style="position: relative; bottom: -7px"/> and <img src="../_images/mathmpl/math-0938c51d1a.png" style="position: relative; bottom: -10px"/>.</dd>
</dl>
</div>
</dd></dl>
<dl class="function">
<dt id="matplotlib.mlab.cohere_pairs">
<tt class="descclassname">matplotlib.mlab.</tt><tt class="descname">cohere_pairs</tt><big>(</big><em>X</em>, <em>ij</em>, <em>NFFT=256</em>, <em>Fs=2</em>, <em>detrend=<function detrend_none at 0x2635de8></em>, <em>window=<function window_hanning at 0x2635b90></em>, <em>noverlap=0</em>, <em>preferSpeedOverMemory=True</em>, <em>progressCallback=<function donothing_callback at 0x263b398></em>, <em>returnPxx=False</em><big>)</big><a class="headerlink" href="#matplotlib.mlab.cohere_pairs" title="Permalink to this definition">¶</a></dt>
<dd><p>Call signature:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">Cxy</span><span class="p">,</span> <span class="n">Phase</span><span class="p">,</span> <span class="n">freqs</span> <span class="o">=</span> <span class="n">cohere_pairs</span><span class="p">(</span> <span class="n">X</span><span class="p">,</span> <span class="n">ij</span><span class="p">,</span> <span class="o">...</span><span class="p">)</span>
</pre></div>
</div>
<p>Compute the coherence and phase for all pairs <em>ij</em>, in <em>X</em>.</p>
<p><em>X</em> is a <em>numSamples</em> * <em>numCols</em> array</p>
<p><em>ij</em> is a list of tuples. Each tuple is a pair of indexes into
the columns of X for which you want to compute coherence. For
example, if <em>X</em> has 64 columns, and you want to compute all
nonredundant pairs, define <em>ij</em> as:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">ij</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">64</span><span class="p">):</span>
<span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">i</span><span class="o">+</span><span class="mi">1</span><span class="p">,</span><span class="mi">64</span><span class="p">):</span>
<span class="n">ij</span><span class="o">.</span><span class="n">append</span><span class="p">(</span> <span class="p">(</span><span class="n">i</span><span class="p">,</span><span class="n">j</span><span class="p">)</span> <span class="p">)</span>
</pre></div>
</div>
<p><em>preferSpeedOverMemory</em> is an optional bool. Defaults to true. If
False, limits the caching by only making one, rather than two,
complex cache arrays. This is useful if memory becomes critical.
Even when <em>preferSpeedOverMemory</em> is False, <a class="reference internal" href="#matplotlib.mlab.cohere_pairs" title="matplotlib.mlab.cohere_pairs"><tt class="xref py py-func docutils literal"><span class="pre">cohere_pairs()</span></tt></a>
will still give significant performace gains over calling
<a class="reference internal" href="#matplotlib.mlab.cohere" title="matplotlib.mlab.cohere"><tt class="xref py py-func docutils literal"><span class="pre">cohere()</span></tt></a> for each pair, and will use subtantially less
memory than if <em>preferSpeedOverMemory</em> is True. In my tests with
a 43000,64 array over all nonredundant pairs,
<em>preferSpeedOverMemory</em> = True delivered a 33% performance boost
on a 1.7GHZ Athlon with 512MB RAM compared with
<em>preferSpeedOverMemory</em> = False. But both solutions were more
than 10x faster than naively crunching all possible pairs through
<a class="reference internal" href="#matplotlib.mlab.cohere" title="matplotlib.mlab.cohere"><tt class="xref py py-func docutils literal"><span class="pre">cohere()</span></tt></a>.</p>
<p>Returns:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="p">(</span><span class="n">Cxy</span><span class="p">,</span> <span class="n">Phase</span><span class="p">,</span> <span class="n">freqs</span><span class="p">)</span>
</pre></div>
</div>
<p>where:</p>
<blockquote>
<div><ul>
<li><p class="first"><em>Cxy</em>: dictionary of (<em>i</em>, <em>j</em>) tuples -> coherence vector for
that pair. I.e., <tt class="docutils literal"><span class="pre">Cxy[(i,j)</span> <span class="pre">=</span> <span class="pre">cohere(X[:,i],</span> <span class="pre">X[:,j])</span></tt>.
Number of dictionary keys is <tt class="docutils literal"><span class="pre">len(ij)</span></tt>.</p>
</li>
<li><p class="first"><em>Phase</em>: dictionary of phases of the cross spectral density at
each frequency for each pair. Keys are (<em>i</em>, <em>j</em>).</p>
</li>
<li><dl class="first docutils">
<dt><em>freqs</em>: vector of frequencies, equal in length to either the</dt>
<dd><p class="first last">coherence or phase vectors for any (<em>i</em>, <em>j</em>) key.</p>
</dd>
</dl>
</li>
</ul>
</div></blockquote>
<p>e.g., to make a coherence Bode plot:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">subplot</span><span class="p">(</span><span class="mi">211</span><span class="p">)</span>
<span class="n">plot</span><span class="p">(</span> <span class="n">freqs</span><span class="p">,</span> <span class="n">Cxy</span><span class="p">[(</span><span class="mi">12</span><span class="p">,</span><span class="mi">19</span><span class="p">)])</span>
<span class="n">subplot</span><span class="p">(</span><span class="mi">212</span><span class="p">)</span>
<span class="n">plot</span><span class="p">(</span> <span class="n">freqs</span><span class="p">,</span> <span class="n">Phase</span><span class="p">[(</span><span class="mi">12</span><span class="p">,</span><span class="mi">19</span><span class="p">)])</span>
</pre></div>
</div>
<p>For a large number of pairs, <a class="reference internal" href="#matplotlib.mlab.cohere_pairs" title="matplotlib.mlab.cohere_pairs"><tt class="xref py py-func docutils literal"><span class="pre">cohere_pairs()</span></tt></a> can be much more
efficient than just calling <a class="reference internal" href="#matplotlib.mlab.cohere" title="matplotlib.mlab.cohere"><tt class="xref py py-func docutils literal"><span class="pre">cohere()</span></tt></a> for each pair, because
it caches most of the intensive computations. If <img src="../_images/mathmpl/math-1922d1ceaa.png" style="position: relative; bottom: -3px"/> is the
number of pairs, this function is <img src="../_images/mathmpl/math-98c8089378.png" style="position: relative; bottom: -8px"/> for most of the
heavy lifting, whereas calling cohere for each pair is
<img src="../_images/mathmpl/math-83ff203e39.png" style="position: relative; bottom: -8px"/>. However, because of the caching, it is also more
memory intensive, making 2 additional complex arrays with
approximately the same number of elements as <em>X</em>.</p>
<p>See <tt class="file docutils literal"><span class="pre">test/cohere_pairs_test.py</span></tt> in the src tree for an
example script that shows that this <a class="reference internal" href="#matplotlib.mlab.cohere_pairs" title="matplotlib.mlab.cohere_pairs"><tt class="xref py py-func docutils literal"><span class="pre">cohere_pairs()</span></tt></a> and
<a class="reference internal" href="#matplotlib.mlab.cohere" title="matplotlib.mlab.cohere"><tt class="xref py py-func docutils literal"><span class="pre">cohere()</span></tt></a> give the same results for a given pair.</p>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<dl class="last docutils">
<dt><a class="reference internal" href="#matplotlib.mlab.psd" title="matplotlib.mlab.psd"><tt class="xref py py-func docutils literal"><span class="pre">psd()</span></tt></a></dt>
<dd>For information about the methods used to compute
<img src="../_images/mathmpl/math-0005c3a5e5.png" style="position: relative; bottom: -10px"/>, <img src="../_images/mathmpl/math-f6d65b7f49.png" style="position: relative; bottom: -7px"/> and <img src="../_images/mathmpl/math-0938c51d1a.png" style="position: relative; bottom: -10px"/>.</dd>
</dl>
</div>
</dd></dl>
<dl class="function">
<dt id="matplotlib.mlab.contiguous_regions">
<tt class="descclassname">matplotlib.mlab.</tt><tt class="descname">contiguous_regions</tt><big>(</big><em>mask</em><big>)</big><a class="headerlink" href="#matplotlib.mlab.contiguous_regions" title="Permalink to this definition">¶</a></dt>
<dd><p>return a list of (ind0, ind1) such that mask[ind0:ind1].all() is
True and we cover all such regions</p>
<p>TODO: this is a pure python implementation which probably has a much faster numpy impl</p>
</dd></dl>
<dl class="function">
<dt id="matplotlib.mlab.cross_from_above">
<tt class="descclassname">matplotlib.mlab.</tt><tt class="descname">cross_from_above</tt><big>(</big><em>x</em>, <em>threshold</em><big>)</big><a class="headerlink" href="#matplotlib.mlab.cross_from_above" title="Permalink to this definition">¶</a></dt>
<dd><p>return the indices into <em>x</em> where <em>x</em> crosses some threshold from
below, eg the i’s where:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">x</span><span class="p">[</span><span class="n">i</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">></span><span class="n">threshold</span> <span class="ow">and</span> <span class="n">x</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o"><=</span><span class="n">threshold</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last"><a class="reference internal" href="#matplotlib.mlab.cross_from_below" title="matplotlib.mlab.cross_from_below"><tt class="xref py py-func docutils literal"><span class="pre">cross_from_below()</span></tt></a> and <a class="reference internal" href="#matplotlib.mlab.contiguous_regions" title="matplotlib.mlab.contiguous_regions"><tt class="xref py py-func docutils literal"><span class="pre">contiguous_regions()</span></tt></a></p>
</div>
</dd></dl>
<dl class="function">
<dt id="matplotlib.mlab.cross_from_below">
<tt class="descclassname">matplotlib.mlab.</tt><tt class="descname">cross_from_below</tt><big>(</big><em>x</em>, <em>threshold</em><big>)</big><a class="headerlink" href="#matplotlib.mlab.cross_from_below" title="Permalink to this definition">¶</a></dt>
<dd><p>return the indices into <em>x</em> where <em>x</em> crosses some threshold from
below, eg the i’s where:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">x</span><span class="p">[</span><span class="n">i</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o"><</span><span class="n">threshold</span> <span class="ow">and</span> <span class="n">x</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">>=</span><span class="n">threshold</span>
</pre></div>
</div>
<p>Example code:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">import</span> <span class="nn">matplotlib.pyplot</span> <span class="kn">as</span> <span class="nn">plt</span>
<span class="n">t</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mf">0.0</span><span class="p">,</span> <span class="mf">2.0</span><span class="p">,</span> <span class="mf">0.1</span><span class="p">)</span>
<span class="n">s</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">sin</span><span class="p">(</span><span class="mi">2</span><span class="o">*</span><span class="n">np</span><span class="o">.</span><span class="n">pi</span><span class="o">*</span><span class="n">t</span><span class="p">)</span>
<span class="n">fig</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">figure</span><span class="p">()</span>
<span class="n">ax</span> <span class="o">=</span> <span class="n">fig</span><span class="o">.</span><span class="n">add_subplot</span><span class="p">(</span><span class="mi">111</span><span class="p">)</span>
<span class="n">ax</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="n">s</span><span class="p">,</span> <span class="s">'-o'</span><span class="p">)</span>
<span class="n">ax</span><span class="o">.</span><span class="n">axhline</span><span class="p">(</span><span class="mf">0.5</span><span class="p">)</span>
<span class="n">ax</span><span class="o">.</span><span class="n">axhline</span><span class="p">(</span><span class="o">-</span><span class="mf">0.5</span><span class="p">)</span>
<span class="n">ind</span> <span class="o">=</span> <span class="n">cross_from_below</span><span class="p">(</span><span class="n">s</span><span class="p">,</span> <span class="mf">0.5</span><span class="p">)</span>
<span class="n">ax</span><span class="o">.</span><span class="n">vlines</span><span class="p">(</span><span class="n">t</span><span class="p">[</span><span class="n">ind</span><span class="p">],</span> <span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
<span class="n">ind</span> <span class="o">=</span> <span class="n">cross_from_above</span><span class="p">(</span><span class="n">s</span><span class="p">,</span> <span class="o">-</span><span class="mf">0.5</span><span class="p">)</span>
<span class="n">ax</span><span class="o">.</span><span class="n">vlines</span><span class="p">(</span><span class="n">t</span><span class="p">[</span><span class="n">ind</span><span class="p">],</span> <span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
<span class="n">plt</span><span class="o">.</span><span class="n">show</span><span class="p">()</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last"><a class="reference internal" href="#matplotlib.mlab.cross_from_above" title="matplotlib.mlab.cross_from_above"><tt class="xref py py-func docutils literal"><span class="pre">cross_from_above()</span></tt></a> and <a class="reference internal" href="#matplotlib.mlab.contiguous_regions" title="matplotlib.mlab.contiguous_regions"><tt class="xref py py-func docutils literal"><span class="pre">contiguous_regions()</span></tt></a></p>
</div>
</dd></dl>
<dl class="function">
<dt id="matplotlib.mlab.csd">
<tt class="descclassname">matplotlib.mlab.</tt><tt class="descname">csd</tt><big>(</big><em>x</em>, <em>y</em>, <em>NFFT=256</em>, <em>Fs=2</em>, <em>detrend=<function detrend_none at 0x2635de8></em>, <em>window=<function window_hanning at 0x2635b90></em>, <em>noverlap=0</em>, <em>pad_to=None</em>, <em>sides='default'</em>, <em>scale_by_freq=None</em><big>)</big><a class="headerlink" href="#matplotlib.mlab.csd" title="Permalink to this definition">¶</a></dt>
<dd><p>The cross power spectral density by Welch’s average periodogram
method. The vectors <em>x</em> and <em>y</em> are divided into <em>NFFT</em> length
blocks. Each block is detrended by the function <em>detrend</em> and
windowed by the function <em>window</em>. <em>noverlap</em> gives the length
of the overlap between blocks. The product of the direct FFTs
of <em>x</em> and <em>y</em> are averaged over each segment to compute <em>Pxy</em>,
with a scaling to correct for power loss due to windowing.</p>
<p>If len(<em>x</em>) < <em>NFFT</em> or len(<em>y</em>) < <em>NFFT</em>, they will be zero
padded to <em>NFFT</em>.</p>
<dl class="docutils">
<dt><em>x</em>, <em>y</em></dt>
<dd>Array or sequence containing the data</dd>
</dl>
<p>Keyword arguments:</p>
<blockquote>
<div><dl class="docutils">
<dt><em>NFFT</em>: integer</dt>
<dd>The number of data points used in each block for the FFT.
Must be even; a power 2 is most efficient. The default value is 256.
This should <em>NOT</em> be used to get zero padding, or the scaling of the
result will be incorrect. Use <em>pad_to</em> for this instead.</dd>
<dt><em>Fs</em>: scalar</dt>
<dd>The sampling frequency (samples per time unit). It is used
to calculate the Fourier frequencies, freqs, in cycles per time
unit. The default value is 2.</dd>
<dt><em>detrend</em>: callable</dt>
<dd>The function applied to each segment before fft-ing,
designed to remove the mean or linear trend. Unlike in
MATLAB, where the <em>detrend</em> parameter is a vector, in
matplotlib is it a function. The <tt class="xref py py-mod docutils literal"><span class="pre">pylab</span></tt>
module defines <tt class="xref py py-func docutils literal"><span class="pre">detrend_none()</span></tt>,
<tt class="xref py py-func docutils literal"><span class="pre">detrend_mean()</span></tt>, and
<tt class="xref py py-func docutils literal"><span class="pre">detrend_linear()</span></tt>, but you can use
a custom function as well.</dd>
<dt><em>window</em>: callable or ndarray</dt>
<dd>A function or a vector of length <em>NFFT</em>. To create window
vectors see <a class="reference internal" href="#matplotlib.mlab.window_hanning" title="matplotlib.mlab.window_hanning"><tt class="xref py py-func docutils literal"><span class="pre">window_hanning()</span></tt></a>, <a class="reference internal" href="#matplotlib.mlab.window_none" title="matplotlib.mlab.window_none"><tt class="xref py py-func docutils literal"><span class="pre">window_none()</span></tt></a>,
<tt class="xref py py-func docutils literal"><span class="pre">numpy.blackman()</span></tt>, <tt class="xref py py-func docutils literal"><span class="pre">numpy.hamming()</span></tt>,
<tt class="xref py py-func docutils literal"><span class="pre">numpy.bartlett()</span></tt>, <tt class="xref py py-func docutils literal"><span class="pre">scipy.signal()</span></tt>,
<tt class="xref py py-func docutils literal"><span class="pre">scipy.signal.get_window()</span></tt>, etc. The default is
<a class="reference internal" href="#matplotlib.mlab.window_hanning" title="matplotlib.mlab.window_hanning"><tt class="xref py py-func docutils literal"><span class="pre">window_hanning()</span></tt></a>. If a function is passed as the
argument, it must take a data segment as an argument and
return the windowed version of the segment.</dd>
<dt><em>pad_to</em>: integer</dt>
<dd>The number of points to which the data segment is padded when
performing the FFT. This can be different from <em>NFFT</em>, which
specifies the number of data points used. While not increasing
the actual resolution of the psd (the minimum distance between
resolvable peaks), this can give more points in the plot,
allowing for more detail. This corresponds to the <em>n</em> parameter
in the call to fft(). The default is None, which sets <em>pad_to</em>
equal to <em>NFFT</em></dd>
<dt><em>sides</em>: [ ‘default’ | ‘onesided’ | ‘twosided’ ]</dt>
<dd>Specifies which sides of the PSD to return. Default gives the
default behavior, which returns one-sided for real data and both
for complex data. ‘onesided’ forces the return of a one-sided PSD,
while ‘twosided’ forces two-sided.</dd>
<dt><em>scale_by_freq</em>: boolean</dt>
<dd>Specifies whether the resulting density values should be scaled
by the scaling frequency, which gives density in units of Hz^-1.
This allows for integration over the returned frequency values.
The default is True for MATLAB compatibility.</dd>
<dt><em>noverlap</em>: integer</dt>
<dd>The number of points of overlap between blocks. The default value
is 0 (no overlap).</dd>
</dl>
</div></blockquote>
<p>Returns the tuple (<em>Pxy</em>, <em>freqs</em>).</p>
<dl class="docutils">
<dt>Refs:</dt>
<dd>Bendat & Piersol – Random Data: Analysis and Measurement
Procedures, John Wiley & Sons (1986)</dd>
</dl>
</dd></dl>
<dl class="function">
<dt id="matplotlib.mlab.csv2rec">
<tt class="descclassname">matplotlib.mlab.</tt><tt class="descname">csv2rec</tt><big>(</big><em>fname</em>, <em>comments='#'</em>, <em>skiprows=0</em>, <em>checkrows=0</em>, <em>delimiter='</em>, <em>'</em>, <em>converterd=None</em>, <em>names=None</em>, <em>missing=''</em>, <em>missingd=None</em>, <em>use_mrecords=False</em>, <em>dayfirst=False</em>, <em>yearfirst=False</em><big>)</big><a class="headerlink" href="#matplotlib.mlab.csv2rec" title="Permalink to this definition">¶</a></dt>
<dd><p>Load data from comma/space/tab delimited file in <em>fname</em> into a
numpy record array and return the record array.</p>
<p>If <em>names</em> is <em>None</em>, a header row is required to automatically
assign the recarray names. The headers will be lower cased,
spaces will be converted to underscores, and illegal attribute
name characters removed. If <em>names</em> is not <em>None</em>, it is a
sequence of names to use for the column names. In this case, it
is assumed there is no header row.</p>
<ul>
<li><p class="first"><em>fname</em>: can be a filename or a file handle. Support for gzipped
files is automatic, if the filename ends in ‘.gz’</p>
</li>
<li><p class="first"><em>comments</em>: the character used to indicate the start of a comment
in the file, or <em>None</em> to switch off the removal of comments</p>
</li>
<li><p class="first"><em>skiprows</em>: is the number of rows from the top to skip</p>
</li>
<li><p class="first"><em>checkrows</em>: is the number of rows to check to validate the column
data type. When set to zero all rows are validated.</p>
</li>
<li><p class="first"><em>converterd</em>: if not <em>None</em>, is a dictionary mapping column number or
munged column name to a converter function.</p>
</li>
<li><p class="first"><em>names</em>: if not None, is a list of header names. In this case, no
header will be read from the file</p>
</li>
<li><p class="first"><em>missingd</em> is a dictionary mapping munged column names to field values
which signify that the field does not contain actual data and should
be masked, e.g., ‘0000-00-00’ or ‘unused’</p>
</li>
<li><p class="first"><em>missing</em>: a string whose value signals a missing field regardless of
the column it appears in</p>
</li>
<li><p class="first"><em>use_mrecords</em>: if True, return an mrecords.fromrecords record array if any of the data are missing</p>
</li>
<li><p class="first"><em>dayfirst</em>: default is False so that MM-DD-YY has precedence over
DD-MM-YY. See <a class="reference external" href="http://labix.org/python-dateutil#head-b95ce2094d189a89f80f5ae52a05b4ab7b41af47">http://labix.org/python-dateutil#head-b95ce2094d189a89f80f5ae52a05b4ab7b41af47</a>
for further information.</p>
</li>
<li><p class="first"><em>yearfirst</em>: default is False so that MM-DD-YY has precedence over
YY-MM-DD. See <a class="reference external" href="http://labix.org/python-dateutil#head-b95ce2094d189a89f80f5ae52a05b4ab7b41af47">http://labix.org/python-dateutil#head-b95ce2094d189a89f80f5ae52a05b4ab7b41af47</a>
for further information.</p>
<p>If no rows are found, <em>None</em> is returned – see <tt class="file docutils literal"><span class="pre">examples/loadrec.py</span></tt></p>
</li>
</ul>
</dd></dl>
<dl class="function">
<dt id="matplotlib.mlab.csvformat_factory">
<tt class="descclassname">matplotlib.mlab.</tt><tt class="descname">csvformat_factory</tt><big>(</big><em>format</em><big>)</big><a class="headerlink" href="#matplotlib.mlab.csvformat_factory" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dl class="function">
<dt id="matplotlib.mlab.demean">
<tt class="descclassname">matplotlib.mlab.</tt><tt class="descname">demean</tt><big>(</big><em>x</em>, <em>axis=0</em><big>)</big><a class="headerlink" href="#matplotlib.mlab.demean" title="Permalink to this definition">¶</a></dt>
<dd><p>Return x minus its mean along the specified axis</p>
</dd></dl>
<dl class="function">
<dt id="matplotlib.mlab.detrend">
<tt class="descclassname">matplotlib.mlab.</tt><tt class="descname">detrend</tt><big>(</big><em>x</em>, <em>key=None</em><big>)</big><a class="headerlink" href="#matplotlib.mlab.detrend" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dl class="function">
<dt id="matplotlib.mlab.detrend_linear">
<tt class="descclassname">matplotlib.mlab.</tt><tt class="descname">detrend_linear</tt><big>(</big><em>y</em><big>)</big><a class="headerlink" href="#matplotlib.mlab.detrend_linear" title="Permalink to this definition">¶</a></dt>
<dd><p>Return y minus best fit line; ‘linear’ detrending</p>
</dd></dl>
<dl class="function">
<dt id="matplotlib.mlab.detrend_mean">
<tt class="descclassname">matplotlib.mlab.</tt><tt class="descname">detrend_mean</tt><big>(</big><em>x</em><big>)</big><a class="headerlink" href="#matplotlib.mlab.detrend_mean" title="Permalink to this definition">¶</a></dt>
<dd><p>Return x minus the mean(x)</p>
</dd></dl>
<dl class="function">
<dt id="matplotlib.mlab.detrend_none">
<tt class="descclassname">matplotlib.mlab.</tt><tt class="descname">detrend_none</tt><big>(</big><em>x</em><big>)</big><a class="headerlink" href="#matplotlib.mlab.detrend_none" title="Permalink to this definition">¶</a></dt>
<dd><p>Return x: no detrending</p>
</dd></dl>
<dl class="function">
<dt id="matplotlib.mlab.dist">
<tt class="descclassname">matplotlib.mlab.</tt><tt class="descname">dist</tt><big>(</big><em>x</em>, <em>y</em><big>)</big><a class="headerlink" href="#matplotlib.mlab.dist" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the distance between two points.</p>
</dd></dl>
<dl class="function">
<dt id="matplotlib.mlab.dist_point_to_segment">
<tt class="descclassname">matplotlib.mlab.</tt><tt class="descname">dist_point_to_segment</tt><big>(</big><em>p</em>, <em>s0</em>, <em>s1</em><big>)</big><a class="headerlink" href="#matplotlib.mlab.dist_point_to_segment" title="Permalink to this definition">¶</a></dt>
<dd><p>Get the distance of a point to a segment.</p>
<blockquote>
<div><em>p</em>, <em>s0</em>, <em>s1</em> are <em>xy</em> sequences</div></blockquote>
<p>This algorithm from
<a class="reference external" href="http://softsurfer.com/Archive/algorithm_0102/algorithm_0102.htm#Distance%20to%20Ray%20or%20Segment">http://softsurfer.com/Archive/algorithm_0102/algorithm_0102.htm#Distance%20to%20Ray%20or%20Segment</a></p>
</dd></dl>
<dl class="function">
<dt id="matplotlib.mlab.distances_along_curve">
<tt class="descclassname">matplotlib.mlab.</tt><tt class="descname">distances_along_curve</tt><big>(</big><em>X</em><big>)</big><a class="headerlink" href="#matplotlib.mlab.distances_along_curve" title="Permalink to this definition">¶</a></dt>
<dd><p>Computes the distance between a set of successive points in <em>N</em> dimensions.</p>
<p>Where <em>X</em> is an <em>M</em> x <em>N</em> array or matrix. The distances between
successive rows is computed. Distance is the standard Euclidean
distance.</p>
</dd></dl>
<dl class="function">
<dt id="matplotlib.mlab.donothing_callback">
<tt class="descclassname">matplotlib.mlab.</tt><tt class="descname">donothing_callback</tt><big>(</big><em>*args</em><big>)</big><a class="headerlink" href="#matplotlib.mlab.donothing_callback" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dl class="function">
<dt id="matplotlib.mlab.entropy">
<tt class="descclassname">matplotlib.mlab.</tt><tt class="descname">entropy</tt><big>(</big><em>y</em>, <em>bins</em><big>)</big><a class="headerlink" href="#matplotlib.mlab.entropy" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the entropy of the data in <em>y</em>.</p>
<img src="../_images/mathmpl/math-5c77f15b40.png" class="center" /><p>where <img src="../_images/mathmpl/math-6700e99fd3.png" style="position: relative; bottom: -7px"/> is the probability of observing <em>y</em> in the
<img src="../_images/mathmpl/math-fce1799ac3.png" style="position: relative; bottom: -3px"/> bin of <em>bins</em>. <em>bins</em> can be a number of bins or a
range of bins; see <tt class="xref py py-func docutils literal"><span class="pre">numpy.histogram()</span></tt>.</p>
<p>Compare <em>S</em> with analytic calculation for a Gaussian:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">x</span> <span class="o">=</span> <span class="n">mu</span> <span class="o">+</span> <span class="n">sigma</span> <span class="o">*</span> <span class="n">randn</span><span class="p">(</span><span class="mi">200000</span><span class="p">)</span>
<span class="n">Sanalytic</span> <span class="o">=</span> <span class="mf">0.5</span> <span class="o">*</span> <span class="p">(</span> <span class="mf">1.0</span> <span class="o">+</span> <span class="n">log</span><span class="p">(</span><span class="mi">2</span><span class="o">*</span><span class="n">pi</span><span class="o">*</span><span class="n">sigma</span><span class="o">**</span><span class="mf">2.0</span><span class="p">)</span> <span class="p">)</span>
</pre></div>
</div>
</dd></dl>
<dl class="function">
<dt id="matplotlib.mlab.exp_safe">
<tt class="descclassname">matplotlib.mlab.</tt><tt class="descname">exp_safe</tt><big>(</big><em>x</em><big>)</big><a class="headerlink" href="#matplotlib.mlab.exp_safe" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute exponentials which safely underflow to zero.</p>
<p>Slow, but convenient to use. Note that numpy provides proper
floating point exception handling with access to the underlying
hardware.</p>
</dd></dl>
<dl class="function">
<dt id="matplotlib.mlab.fftsurr">
<tt class="descclassname">matplotlib.mlab.</tt><tt class="descname">fftsurr</tt><big>(</big><em>x</em>, <em>detrend=<function detrend_none at 0x2635de8></em>, <em>window=<function window_none at 0x2635c08></em><big>)</big><a class="headerlink" href="#matplotlib.mlab.fftsurr" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute an FFT phase randomized surrogate of <em>x</em>.</p>
</dd></dl>
<dl class="function">
<dt id="matplotlib.mlab.find">
<tt class="descclassname">matplotlib.mlab.</tt><tt class="descname">find</tt><big>(</big><em>condition</em><big>)</big><a class="headerlink" href="#matplotlib.mlab.find" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the indices where ravel(condition) is true</p>
</dd></dl>
<dl class="function">
<dt id="matplotlib.mlab.frange">
<tt class="descclassname">matplotlib.mlab.</tt><tt class="descname">frange</tt><big>(</big><span class="optional">[</span><em>start</em><span class="optional">]</span>, <em>stop</em><span class="optional">[</span>, <em>step</em>, <em>keywords</em><span class="optional">]</span><big>)</big> → array of floats<a class="headerlink" href="#matplotlib.mlab.frange" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a numpy ndarray containing a progression of floats. Similar to
<tt class="xref py py-func docutils literal"><span class="pre">numpy.arange()</span></tt>, but defaults to a closed interval.</p>
<p><tt class="docutils literal"><span class="pre">frange(x0,</span> <span class="pre">x1)</span></tt> returns <tt class="docutils literal"><span class="pre">[x0,</span> <span class="pre">x0+1,</span> <span class="pre">x0+2,</span> <span class="pre">...,</span> <span class="pre">x1]</span></tt>; <em>start</em>
defaults to 0, and the endpoint <em>is included</em>. This behavior is
different from that of <tt class="xref py py-func docutils literal"><span class="pre">range()</span></tt> and
<tt class="xref py py-func docutils literal"><span class="pre">numpy.arange()</span></tt>. This is deliberate, since <a class="reference internal" href="#matplotlib.mlab.frange" title="matplotlib.mlab.frange"><tt class="xref py py-func docutils literal"><span class="pre">frange()</span></tt></a>
will probably be more useful for generating lists of points for
function evaluation, and endpoints are often desired in this
use. The usual behavior of <tt class="xref py py-func docutils literal"><span class="pre">range()</span></tt> can be obtained by
setting the keyword <em>closed</em> = 0, in this case, <a class="reference internal" href="#matplotlib.mlab.frange" title="matplotlib.mlab.frange"><tt class="xref py py-func docutils literal"><span class="pre">frange()</span></tt></a>
basically becomes :func:numpy.arange`.</p>
<p>When <em>step</em> is given, it specifies the increment (or
decrement). All arguments can be floating point numbers.</p>
<p><tt class="docutils literal"><span class="pre">frange(x0,x1,d)</span></tt> returns <tt class="docutils literal"><span class="pre">[x0,x0+d,x0+2d,...,xfin]</span></tt> where
<em>xfin</em> <= <em>x1</em>.</p>
<p><a class="reference internal" href="#matplotlib.mlab.frange" title="matplotlib.mlab.frange"><tt class="xref py py-func docutils literal"><span class="pre">frange()</span></tt></a> can also be called with the keyword <em>npts</em>. This
sets the number of points the list should contain (and overrides
the value <em>step</em> might have been given). <tt class="xref py py-func docutils literal"><span class="pre">numpy.arange()</span></tt>
doesn’t offer this option.</p>
<p>Examples:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="n">frange</span><span class="p">(</span><span class="mi">3</span><span class="p">)</span>