12
12
import numpy as np
13
13
import matplotlib .pyplot as plt
14
14
import matplotlib .colors as mcolors
15
+ from matplotlib .patches import Rectangle
15
16
16
17
# Fixing random state for reproducibility
17
18
np .random .seed (19680801 )
@@ -65,6 +66,14 @@ def plot_colored_circles(ax, prng, nb_samples=15):
65
66
for sty_dict , j in zip (plt .rcParams ['axes.prop_cycle' ], range (nb_samples )):
66
67
ax .add_patch (plt .Circle (prng .normal (scale = 3 , size = 2 ),
67
68
radius = 1.0 , color = sty_dict ['color' ]))
69
+
70
+ ax .grid (visible = True )
71
+ # Add annotation for enabling grid
72
+ ax .annotate ('ax.grid(True)' , xy = (1 , 1 ),
73
+ xytext = (5 , 8 ),
74
+ va = "top" , ha = "right" ,
75
+ )
76
+
68
77
# Force the limits to be the same across the styles (because different
69
78
# styles may have different numbers of available colors).
70
79
ax .set_xlim ([- 4 , 8 ])
@@ -110,7 +119,7 @@ def plot_figure(style_label=""):
110
119
prng = np .random .RandomState (96917002 )
111
120
112
121
fig , axs = plt .subplots (ncols = 6 , nrows = 1 , num = style_label ,
113
- figsize = (14.8 , 2.7 ), constrained_layout = True )
122
+ figsize = (14.8 , 2.8 ), constrained_layout = True )
114
123
115
124
# make a suptitle, in the same style for all subfigures,
116
125
# except those with dark backgrounds, which get a lighter color:
@@ -126,9 +135,18 @@ def plot_figure(style_label=""):
126
135
plot_scatter (axs [0 ], prng )
127
136
plot_image_and_patch (axs [1 ], prng )
128
137
plot_bar_graphs (axs [2 ], prng )
129
- plot_colored_circles (axs [3 ], prng )
130
- plot_colored_lines (axs [4 ])
131
- plot_histograms (axs [5 ], prng )
138
+ plot_colored_lines (axs [3 ])
139
+ plot_histograms (axs [4 ], prng )
140
+ plot_colored_circles (axs [5 ], prng )
141
+
142
+ # add divider
143
+ rec = Rectangle (
144
+ (1 + 0.025 , - 2 ),
145
+ 0.05 , 16 ,
146
+ clip_on = False ,
147
+ color = 'gray' )
148
+
149
+ axs [4 ].add_artist (rec )
132
150
133
151
134
152
if __name__ == "__main__" :
0 commit comments