Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

Think Stats by Allen B. Downey Think Stats is an introduction to Probability and Statistics for Python programmers.

This is the accompanying code for this book.

Website: http://greenteapress.com/wp/think-stats-2e/

Views: 7089
License: GPL3
1
"""This file contains code for use with "Think Stats",
2
by Allen B. Downey, available from greenteapress.com
3
4
Copyright 2014 Allen B. Downey
5
License: GNU GPLv3 http://www.gnu.org/licenses/gpl.html
6
"""
7
8
from __future__ import print_function
9
10
import math
11
import matplotlib
12
import matplotlib.pyplot as plt
13
import numpy as np
14
import pandas as pd
15
16
import warnings
17
18
# customize some matplotlib attributes
19
#matplotlib.rc('figure', figsize=(4, 3))
20
21
#matplotlib.rc('font', size=14.0)
22
#matplotlib.rc('axes', labelsize=22.0, titlesize=22.0)
23
#matplotlib.rc('legend', fontsize=20.0)
24
25
#matplotlib.rc('xtick.major', size=6.0)
26
#matplotlib.rc('xtick.minor', size=3.0)
27
28
#matplotlib.rc('ytick.major', size=6.0)
29
#matplotlib.rc('ytick.minor', size=3.0)
30
31
32
class _Brewer(object):
33
"""Encapsulates a nice sequence of colors.
34
35
Shades of blue that look good in color and can be distinguished
36
in grayscale (up to a point).
37
38
Borrowed from http://colorbrewer2.org/
39
"""
40
color_iter = None
41
42
colors = ['#f7fbff', '#deebf7', '#c6dbef',
43
'#9ecae1', '#6baed6', '#4292c6',
44
'#2171b5','#08519c','#08306b'][::-1]
45
46
# lists that indicate which colors to use depending on how many are used
47
which_colors = [[],
48
[1],
49
[1, 3],
50
[0, 2, 4],
51
[0, 2, 4, 6],
52
[0, 2, 3, 5, 6],
53
[0, 2, 3, 4, 5, 6],
54
[0, 1, 2, 3, 4, 5, 6],
55
[0, 1, 2, 3, 4, 5, 6, 7],
56
[0, 1, 2, 3, 4, 5, 6, 7, 8],
57
]
58
59
current_figure = None
60
61
@classmethod
62
def Colors(cls):
63
"""Returns the list of colors.
64
"""
65
return cls.colors
66
67
@classmethod
68
def ColorGenerator(cls, num):
69
"""Returns an iterator of color strings.
70
71
n: how many colors will be used
72
"""
73
for i in cls.which_colors[num]:
74
yield cls.colors[i]
75
raise StopIteration('Ran out of colors in _Brewer.')
76
77
@classmethod
78
def InitIter(cls, num):
79
"""Initializes the color iterator with the given number of colors."""
80
cls.color_iter = cls.ColorGenerator(num)
81
fig = plt.gcf()
82
cls.current_figure = fig
83
84
@classmethod
85
def ClearIter(cls):
86
"""Sets the color iterator to None."""
87
cls.color_iter = None
88
cls.current_figure = None
89
90
@classmethod
91
def GetIter(cls, num):
92
"""Gets the color iterator."""
93
fig = plt.gcf()
94
if fig != cls.current_figure:
95
cls.InitIter(num)
96
cls.current_figure = fig
97
98
if cls.color_iter is None:
99
cls.InitIter(num)
100
101
return cls.color_iter
102
103
104
def _UnderrideColor(options):
105
"""If color is not in the options, chooses a color.
106
"""
107
if 'color' in options:
108
return options
109
110
# get the current color iterator; if there is none, init one
111
color_iter = _Brewer.GetIter(5)
112
113
try:
114
options['color'] = next(color_iter)
115
except StopIteration:
116
# if you run out of colors, initialize the color iterator
117
# and try again
118
warnings.warn('Ran out of colors. Starting over.')
119
_Brewer.ClearIter()
120
_UnderrideColor(options)
121
122
return options
123
124
125
def PrePlot(num=None, rows=None, cols=None):
126
"""Takes hints about what's coming.
127
128
num: number of lines that will be plotted
129
rows: number of rows of subplots
130
cols: number of columns of subplots
131
"""
132
if num:
133
_Brewer.InitIter(num)
134
135
if rows is None and cols is None:
136
return
137
138
if rows is not None and cols is None:
139
cols = 1
140
141
if cols is not None and rows is None:
142
rows = 1
143
144
# resize the image, depending on the number of rows and cols
145
size_map = {(1, 1): (8, 6),
146
(1, 2): (12, 6),
147
(1, 3): (12, 6),
148
(1, 4): (12, 5),
149
(1, 5): (12, 4),
150
(2, 2): (10, 10),
151
(2, 3): (16, 10),
152
(3, 1): (8, 10),
153
(4, 1): (8, 12),
154
}
155
156
if (rows, cols) in size_map:
157
fig = plt.gcf()
158
fig.set_size_inches(*size_map[rows, cols])
159
160
# create the first subplot
161
if rows > 1 or cols > 1:
162
ax = plt.subplot(rows, cols, 1)
163
global SUBPLOT_ROWS, SUBPLOT_COLS
164
SUBPLOT_ROWS = rows
165
SUBPLOT_COLS = cols
166
else:
167
ax = plt.gca()
168
169
return ax
170
171
172
def SubPlot(plot_number, rows=None, cols=None, **options):
173
"""Configures the number of subplots and changes the current plot.
174
175
rows: int
176
cols: int
177
plot_number: int
178
options: passed to subplot
179
"""
180
rows = rows or SUBPLOT_ROWS
181
cols = cols or SUBPLOT_COLS
182
return plt.subplot(rows, cols, plot_number, **options)
183
184
185
def _Underride(d, **options):
186
"""Add key-value pairs to d only if key is not in d.
187
188
If d is None, create a new dictionary.
189
190
d: dictionary
191
options: keyword args to add to d
192
"""
193
if d is None:
194
d = {}
195
196
for key, val in options.items():
197
d.setdefault(key, val)
198
199
return d
200
201
202
def Clf():
203
"""Clears the figure and any hints that have been set."""
204
global LOC
205
LOC = None
206
_Brewer.ClearIter()
207
plt.clf()
208
fig = plt.gcf()
209
fig.set_size_inches(8, 6)
210
211
212
def Figure(**options):
213
"""Sets options for the current figure."""
214
_Underride(options, figsize=(6, 8))
215
plt.figure(**options)
216
217
218
def Plot(obj, ys=None, style='', **options):
219
"""Plots a line.
220
221
Args:
222
obj: sequence of x values, or Series, or anything with Render()
223
ys: sequence of y values
224
style: style string passed along to plt.plot
225
options: keyword args passed to plt.plot
226
"""
227
options = _UnderrideColor(options)
228
label = getattr(obj, 'label', '_nolegend_')
229
options = _Underride(options, linewidth=3, alpha=0.7, label=label)
230
231
xs = obj
232
if ys is None:
233
if hasattr(obj, 'Render'):
234
xs, ys = obj.Render()
235
if isinstance(obj, pd.Series):
236
ys = obj.values
237
xs = obj.index
238
239
if ys is None:
240
plt.plot(xs, style, **options)
241
else:
242
plt.plot(xs, ys, style, **options)
243
244
245
def Vlines(xs, y1, y2, **options):
246
"""Plots a set of vertical lines.
247
248
Args:
249
xs: sequence of x values
250
y1: sequence of y values
251
y2: sequence of y values
252
options: keyword args passed to plt.vlines
253
"""
254
options = _UnderrideColor(options)
255
options = _Underride(options, linewidth=1, alpha=0.5)
256
plt.vlines(xs, y1, y2, **options)
257
258
259
def Hlines(ys, x1, x2, **options):
260
"""Plots a set of horizontal lines.
261
262
Args:
263
ys: sequence of y values
264
x1: sequence of x values
265
x2: sequence of x values
266
options: keyword args passed to plt.vlines
267
"""
268
options = _UnderrideColor(options)
269
options = _Underride(options, linewidth=1, alpha=0.5)
270
plt.hlines(ys, x1, x2, **options)
271
272
273
def axvline(x, **options):
274
"""Plots a vertical line.
275
276
Args:
277
x: x location
278
options: keyword args passed to plt.axvline
279
"""
280
options = _UnderrideColor(options)
281
options = _Underride(options, linewidth=1, alpha=0.5)
282
plt.axvline(x, **options)
283
284
285
def axhline(y, **options):
286
"""Plots a horizontal line.
287
288
Args:
289
y: y location
290
options: keyword args passed to plt.axhline
291
"""
292
options = _UnderrideColor(options)
293
options = _Underride(options, linewidth=1, alpha=0.5)
294
plt.axhline(y, **options)
295
296
297
def tight_layout(**options):
298
"""Adjust subplots to minimize padding and margins.
299
"""
300
options = _Underride(options,
301
wspace=0.1, hspace=0.1,
302
left=0, right=1,
303
bottom=0, top=1)
304
plt.tight_layout()
305
plt.subplots_adjust(**options)
306
307
308
def FillBetween(xs, y1, y2=None, where=None, **options):
309
"""Fills the space between two lines.
310
311
Args:
312
xs: sequence of x values
313
y1: sequence of y values
314
y2: sequence of y values
315
where: sequence of boolean
316
options: keyword args passed to plt.fill_between
317
"""
318
options = _UnderrideColor(options)
319
options = _Underride(options, linewidth=0, alpha=0.5)
320
plt.fill_between(xs, y1, y2, where, **options)
321
322
323
def Bar(xs, ys, **options):
324
"""Plots a line.
325
326
Args:
327
xs: sequence of x values
328
ys: sequence of y values
329
options: keyword args passed to plt.bar
330
"""
331
options = _UnderrideColor(options)
332
options = _Underride(options, linewidth=0, alpha=0.6)
333
plt.bar(xs, ys, **options)
334
335
336
def Scatter(xs, ys=None, **options):
337
"""Makes a scatter plot.
338
339
xs: x values
340
ys: y values
341
options: options passed to plt.scatter
342
"""
343
options = _Underride(options, color='blue', alpha=0.2,
344
s=30, edgecolors='none')
345
346
if ys is None and isinstance(xs, pd.Series):
347
ys = xs.values
348
xs = xs.index
349
350
plt.scatter(xs, ys, **options)
351
352
353
def HexBin(xs, ys, **options):
354
"""Makes a scatter plot.
355
356
xs: x values
357
ys: y values
358
options: options passed to plt.scatter
359
"""
360
options = _Underride(options, cmap=matplotlib.cm.Blues)
361
plt.hexbin(xs, ys, **options)
362
363
364
def Pdf(pdf, **options):
365
"""Plots a Pdf, Pmf, or Hist as a line.
366
367
Args:
368
pdf: Pdf, Pmf, or Hist object
369
options: keyword args passed to plt.plot
370
"""
371
low, high = options.pop('low', None), options.pop('high', None)
372
n = options.pop('n', 101)
373
xs, ps = pdf.Render(low=low, high=high, n=n)
374
options = _Underride(options, label=pdf.label)
375
Plot(xs, ps, **options)
376
377
378
def Pdfs(pdfs, **options):
379
"""Plots a sequence of PDFs.
380
381
Options are passed along for all PDFs. If you want different
382
options for each pdf, make multiple calls to Pdf.
383
384
Args:
385
pdfs: sequence of PDF objects
386
options: keyword args passed to plt.plot
387
"""
388
for pdf in pdfs:
389
Pdf(pdf, **options)
390
391
392
def Hist(hist, **options):
393
"""Plots a Pmf or Hist with a bar plot.
394
395
The default width of the bars is based on the minimum difference
396
between values in the Hist. If that's too small, you can override
397
it by providing a width keyword argument, in the same units
398
as the values.
399
400
Args:
401
hist: Hist or Pmf object
402
options: keyword args passed to plt.bar
403
"""
404
# find the minimum distance between adjacent values
405
xs, ys = hist.Render()
406
407
# see if the values support arithmetic
408
try:
409
xs[0] - xs[0]
410
except TypeError:
411
# if not, replace values with numbers
412
labels = [str(x) for x in xs]
413
xs = np.arange(len(xs))
414
plt.xticks(xs+0.5, labels)
415
416
if 'width' not in options:
417
try:
418
options['width'] = 0.9 * np.diff(xs).min()
419
except TypeError:
420
warnings.warn("Hist: Can't compute bar width automatically."
421
"Check for non-numeric types in Hist."
422
"Or try providing width option."
423
)
424
425
options = _Underride(options, label=hist.label)
426
options = _Underride(options, align='center')
427
if options['align'] == 'left':
428
options['align'] = 'edge'
429
elif options['align'] == 'right':
430
options['align'] = 'edge'
431
options['width'] *= -1
432
433
Bar(xs, ys, **options)
434
435
436
def Hists(hists, **options):
437
"""Plots two histograms as interleaved bar plots.
438
439
Options are passed along for all PMFs. If you want different
440
options for each pmf, make multiple calls to Pmf.
441
442
Args:
443
hists: list of two Hist or Pmf objects
444
options: keyword args passed to plt.plot
445
"""
446
for hist in hists:
447
Hist(hist, **options)
448
449
450
def Pmf(pmf, **options):
451
"""Plots a Pmf or Hist as a line.
452
453
Args:
454
pmf: Hist or Pmf object
455
options: keyword args passed to plt.plot
456
"""
457
xs, ys = pmf.Render()
458
low, high = min(xs), max(xs)
459
460
width = options.pop('width', None)
461
if width is None:
462
try:
463
width = np.diff(xs).min()
464
except TypeError:
465
warnings.warn("Pmf: Can't compute bar width automatically."
466
"Check for non-numeric types in Pmf."
467
"Or try providing width option.")
468
points = []
469
470
lastx = np.nan
471
lasty = 0
472
for x, y in zip(xs, ys):
473
if (x - lastx) > 1e-5:
474
points.append((lastx, 0))
475
points.append((x, 0))
476
477
points.append((x, lasty))
478
points.append((x, y))
479
points.append((x+width, y))
480
481
lastx = x + width
482
lasty = y
483
points.append((lastx, 0))
484
pxs, pys = zip(*points)
485
486
align = options.pop('align', 'center')
487
if align == 'center':
488
pxs = np.array(pxs) - width/2.0
489
if align == 'right':
490
pxs = np.array(pxs) - width
491
492
options = _Underride(options, label=pmf.label)
493
Plot(pxs, pys, **options)
494
495
496
def Pmfs(pmfs, **options):
497
"""Plots a sequence of PMFs.
498
499
Options are passed along for all PMFs. If you want different
500
options for each pmf, make multiple calls to Pmf.
501
502
Args:
503
pmfs: sequence of PMF objects
504
options: keyword args passed to plt.plot
505
"""
506
for pmf in pmfs:
507
Pmf(pmf, **options)
508
509
510
def Diff(t):
511
"""Compute the differences between adjacent elements in a sequence.
512
513
Args:
514
t: sequence of number
515
516
Returns:
517
sequence of differences (length one less than t)
518
"""
519
diffs = [t[i+1] - t[i] for i in range(len(t)-1)]
520
return diffs
521
522
523
def Cdf(cdf, complement=False, transform=None, **options):
524
"""Plots a CDF as a line.
525
526
Args:
527
cdf: Cdf object
528
complement: boolean, whether to plot the complementary CDF
529
transform: string, one of 'exponential', 'pareto', 'weibull', 'gumbel'
530
options: keyword args passed to plt.plot
531
532
Returns:
533
dictionary with the scale options that should be passed to
534
Config, Show or Save.
535
"""
536
xs, ps = cdf.Render()
537
xs = np.asarray(xs)
538
ps = np.asarray(ps)
539
540
scale = dict(xscale='linear', yscale='linear')
541
542
for s in ['xscale', 'yscale']:
543
if s in options:
544
scale[s] = options.pop(s)
545
546
if transform == 'exponential':
547
complement = True
548
scale['yscale'] = 'log'
549
550
if transform == 'pareto':
551
complement = True
552
scale['yscale'] = 'log'
553
scale['xscale'] = 'log'
554
555
if complement:
556
ps = [1.0-p for p in ps]
557
558
if transform == 'weibull':
559
xs = np.delete(xs, -1)
560
ps = np.delete(ps, -1)
561
ps = [-math.log(1.0-p) for p in ps]
562
scale['xscale'] = 'log'
563
scale['yscale'] = 'log'
564
565
if transform == 'gumbel':
566
xs = np.delete(xs, 0)
567
ps = np.delete(ps, 0)
568
ps = [-math.log(p) for p in ps]
569
scale['yscale'] = 'log'
570
571
options = _Underride(options, label=cdf.label)
572
Plot(xs, ps, **options)
573
return scale
574
575
576
def Cdfs(cdfs, complement=False, transform=None, **options):
577
"""Plots a sequence of CDFs.
578
579
cdfs: sequence of CDF objects
580
complement: boolean, whether to plot the complementary CDF
581
transform: string, one of 'exponential', 'pareto', 'weibull', 'gumbel'
582
options: keyword args passed to plt.plot
583
"""
584
for cdf in cdfs:
585
Cdf(cdf, complement, transform, **options)
586
587
588
def Contour(obj, pcolor=False, contour=True, imshow=False, **options):
589
"""Makes a contour plot.
590
591
d: map from (x, y) to z, or object that provides GetDict
592
pcolor: boolean, whether to make a pseudocolor plot
593
contour: boolean, whether to make a contour plot
594
imshow: boolean, whether to use plt.imshow
595
options: keyword args passed to plt.pcolor and/or plt.contour
596
"""
597
try:
598
d = obj.GetDict()
599
except AttributeError:
600
d = obj
601
602
_Underride(options, linewidth=3, cmap=matplotlib.cm.Blues)
603
604
xs, ys = zip(*d.keys())
605
xs = sorted(set(xs))
606
ys = sorted(set(ys))
607
608
X, Y = np.meshgrid(xs, ys)
609
func = lambda x, y: d.get((x, y), 0)
610
func = np.vectorize(func)
611
Z = func(X, Y)
612
613
x_formatter = matplotlib.ticker.ScalarFormatter(useOffset=False)
614
axes = plt.gca()
615
axes.xaxis.set_major_formatter(x_formatter)
616
617
if pcolor:
618
plt.pcolormesh(X, Y, Z, **options)
619
if contour:
620
cs = plt.contour(X, Y, Z, **options)
621
plt.clabel(cs, inline=1, fontsize=10)
622
if imshow:
623
extent = xs[0], xs[-1], ys[0], ys[-1]
624
plt.imshow(Z, extent=extent, **options)
625
626
627
def Pcolor(xs, ys, zs, pcolor=True, contour=False, **options):
628
"""Makes a pseudocolor plot.
629
630
xs:
631
ys:
632
zs:
633
pcolor: boolean, whether to make a pseudocolor plot
634
contour: boolean, whether to make a contour plot
635
options: keyword args passed to plt.pcolor and/or plt.contour
636
"""
637
_Underride(options, linewidth=3, cmap=matplotlib.cm.Blues)
638
639
X, Y = np.meshgrid(xs, ys)
640
Z = zs
641
642
x_formatter = matplotlib.ticker.ScalarFormatter(useOffset=False)
643
axes = plt.gca()
644
axes.xaxis.set_major_formatter(x_formatter)
645
646
if pcolor:
647
plt.pcolormesh(X, Y, Z, **options)
648
649
if contour:
650
cs = plt.contour(X, Y, Z, **options)
651
plt.clabel(cs, inline=1, fontsize=10)
652
653
654
def Text(x, y, s, **options):
655
"""Puts text in a figure.
656
657
x: number
658
y: number
659
s: string
660
options: keyword args passed to plt.text
661
"""
662
options = _Underride(options,
663
fontsize=16,
664
verticalalignment='top',
665
horizontalalignment='left')
666
plt.text(x, y, s, **options)
667
668
669
LEGEND = True
670
LOC = None
671
672
def Config(**options):
673
"""Configures the plot.
674
675
Pulls options out of the option dictionary and passes them to
676
the corresponding plt functions.
677
"""
678
names = ['title', 'xlabel', 'ylabel', 'xscale', 'yscale',
679
'xticks', 'yticks', 'axis', 'xlim', 'ylim']
680
681
for name in names:
682
if name in options:
683
getattr(plt, name)(options[name])
684
685
global LEGEND
686
LEGEND = options.get('legend', LEGEND)
687
688
# see if there are any elements with labels;
689
# if not, don't draw a legend
690
ax = plt.gca()
691
handles, labels = ax.get_legend_handles_labels()
692
693
if LEGEND and len(labels) > 0:
694
global LOC
695
LOC = options.get('loc', LOC)
696
frameon = options.get('frameon', True)
697
698
try:
699
plt.legend(loc=LOC, frameon=frameon)
700
except UserWarning:
701
pass
702
703
# x and y ticklabels can be made invisible
704
val = options.get('xticklabels', None)
705
if val is not None:
706
if val == 'invisible':
707
ax = plt.gca()
708
labels = ax.get_xticklabels()
709
plt.setp(labels, visible=False)
710
711
val = options.get('yticklabels', None)
712
if val is not None:
713
if val == 'invisible':
714
ax = plt.gca()
715
labels = ax.get_yticklabels()
716
plt.setp(labels, visible=False)
717
718
def set_font_size(title_size=16, label_size=16, ticklabel_size=14, legend_size=14):
719
"""Set font sizes for the title, labels, ticklabels, and legend.
720
"""
721
def set_text_size(texts, size):
722
for text in texts:
723
text.set_size(size)
724
725
ax = plt.gca()
726
727
# TODO: Make this function more robust if any of these elements
728
# is missing.
729
730
# title
731
ax.title.set_size(title_size)
732
733
# x axis
734
ax.xaxis.label.set_size(label_size)
735
set_text_size(ax.xaxis.get_ticklabels(), ticklabel_size)
736
737
# y axis
738
ax.yaxis.label.set_size(label_size)
739
set_text_size(ax.yaxis.get_ticklabels(), ticklabel_size)
740
741
# legend
742
legend = ax.get_legend()
743
if legend is not None:
744
set_text_size(legend.texts, legend_size)
745
746
747
def bigger_text():
748
sizes = dict(title_size=16, label_size=16, ticklabel_size=14, legend_size=14)
749
set_font_size(**sizes)
750
751
752
def Show(**options):
753
"""Shows the plot.
754
755
For options, see Config.
756
757
options: keyword args used to invoke various plt functions
758
"""
759
clf = options.pop('clf', True)
760
Config(**options)
761
plt.show()
762
if clf:
763
Clf()
764
765
766
def Plotly(**options):
767
"""Shows the plot.
768
769
For options, see Config.
770
771
options: keyword args used to invoke various plt functions
772
"""
773
clf = options.pop('clf', True)
774
Config(**options)
775
import plotly.plotly as plotly
776
url = plotly.plot_mpl(plt.gcf())
777
if clf:
778
Clf()
779
return url
780
781
782
def Save(root=None, formats=None, **options):
783
"""Saves the plot in the given formats and clears the figure.
784
785
For options, see Config.
786
787
Note: With a capital S, this is the original save, maintained for
788
compatibility. New code should use save(), which works better
789
with my newer code, especially in Jupyter notebooks.
790
791
Args:
792
root: string filename root
793
formats: list of string formats
794
options: keyword args used to invoke various plt functions
795
"""
796
clf = options.pop('clf', True)
797
798
save_options = {}
799
for option in ['bbox_inches', 'pad_inches']:
800
if option in options:
801
save_options[option] = options.pop(option)
802
803
# TODO: falling Config inside Save was probably a mistake, but removing
804
# it will require some work
805
Config(**options)
806
807
if formats is None:
808
formats = ['pdf', 'png']
809
810
try:
811
formats.remove('plotly')
812
Plotly(clf=False)
813
except ValueError:
814
pass
815
816
if root:
817
for fmt in formats:
818
SaveFormat(root, fmt, **save_options)
819
if clf:
820
Clf()
821
822
823
def save(root, formats=None, **options):
824
"""Saves the plot in the given formats and clears the figure.
825
826
For options, see plt.savefig.
827
828
Args:
829
root: string filename root
830
formats: list of string formats
831
options: keyword args passed to plt.savefig
832
"""
833
if formats is None:
834
formats = ['pdf', 'png']
835
836
try:
837
formats.remove('plotly')
838
Plotly(clf=False)
839
except ValueError:
840
pass
841
842
for fmt in formats:
843
SaveFormat(root, fmt, **options)
844
845
846
def SaveFormat(root, fmt='eps', **options):
847
"""Writes the current figure to a file in the given format.
848
849
Args:
850
root: string filename root
851
fmt: string format
852
"""
853
_Underride(options, dpi=300)
854
filename = '%s.%s' % (root, fmt)
855
print('Writing', filename)
856
plt.savefig(filename, format=fmt, **options)
857
858
859
# provide aliases for calling functions with lower-case names
860
preplot = PrePlot
861
subplot = SubPlot
862
clf = Clf
863
figure = Figure
864
plot = Plot
865
vlines = Vlines
866
hlines = Hlines
867
fill_between = FillBetween
868
text = Text
869
scatter = Scatter
870
pmf = Pmf
871
pmfs = Pmfs
872
hist = Hist
873
hists = Hists
874
diff = Diff
875
cdf = Cdf
876
cdfs = Cdfs
877
contour = Contour
878
pcolor = Pcolor
879
config = Config
880
show = Show
881
882
883
def main():
884
color_iter = _Brewer.ColorGenerator(7)
885
for color in color_iter:
886
print(color)
887
888
889
if __name__ == '__main__':
890
main()
891
892