7
7
import numpy as np
8
8
import matplotlib .pyplot as plt
9
9
10
+
10
11
def plot_scatter (ax , prng , nb_samples = 200 ):
11
12
""" Scatter plot.
12
13
13
14
NB: `plt.scatter` doesn't use default colors.
14
15
"""
15
16
x , y = prng .normal (size = (2 , nb_samples ))
16
17
ax .plot (x , y , 'o' )
18
+ ax .set_xlabel ('X-label' )
19
+ ax .set_ylabel ('Y-label' )
17
20
return ax
18
21
22
+
19
23
def plot_colored_sinusoidal_lines (ax ):
20
24
""" Plot sinusoidal lines with colors from default color cycle.
21
25
"""
@@ -28,6 +32,7 @@ def plot_colored_sinusoidal_lines(ax):
28
32
ax .margins (0 )
29
33
return ax
30
34
35
+
31
36
def plot_bar_graphs (ax , prng , min_value = 5 , max_value = 25 , nb_samples = 5 ):
32
37
""" Plot two bar graphs side by side, with letters as xticklabels.
33
38
"""
@@ -40,6 +45,7 @@ def plot_bar_graphs(ax, prng, min_value=5, max_value=25, nb_samples=5):
40
45
ax .set_xticklabels (['a' , 'b' , 'c' , 'd' , 'e' ])
41
46
return ax
42
47
48
+
43
49
def plot_colored_circles (ax , prng , nb_samples = 15 ):
44
50
""" Plot circle patches.
45
51
@@ -58,6 +64,7 @@ def plot_colored_circles(ax, prng, nb_samples=15):
58
64
ax .set_aspect ('equal' , adjustable = 'box' ) # to plot circles as circles
59
65
return ax
60
66
67
+
61
68
def plot_image_and_patch (ax , prng , size = (20 , 20 )):
62
69
""" Plot an image with random values and superimpose a circular patch.
63
70
"""
@@ -66,6 +73,7 @@ def plot_image_and_patch(ax, prng, size=(20, 20)):
66
73
c = plt .Circle ((5 , 5 ), radius = 5 , label = 'patch' )
67
74
ax .add_patch (c )
68
75
76
+
69
77
def plot_histograms (ax , prng , nb_samples = 10000 ):
70
78
""" Plot 4 histograms and a text annotation.
71
79
"""
@@ -82,12 +90,13 @@ def plot_histograms(ax, prng, nb_samples=10000):
82
90
)
83
91
return ax
84
92
93
+
85
94
def plot_figure (style_label = None ):
86
- """
95
+ """
87
96
Setup and plot the demonstration figure with the style `style_label`.
88
97
If `style_label`, fall back to the `default` style.
89
98
"""
90
- if style_label == None :
99
+ if style_label is None :
91
100
style_label = 'default'
92
101
93
102
# Use a dedicated RandomState instance to draw the same "random" values across
@@ -116,4 +125,3 @@ def plot_figure(style_label=None):
116
125
fig = plot_figure (style_label = style_label )
117
126
118
127
plt .show ()
119
-
0 commit comments