Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3f741a1

Browse files
committed
add divider and annotation.
1 parent 14c96b5 commit 3f741a1

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

examples/style_sheets/style_sheets_reference.py

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import numpy as np
1313
import matplotlib.pyplot as plt
1414
import matplotlib.colors as mcolors
15+
from matplotlib.patches import Rectangle
1516

1617
# Fixing random state for reproducibility
1718
np.random.seed(19680801)
@@ -65,6 +66,14 @@ def plot_colored_circles(ax, prng, nb_samples=15):
6566
for sty_dict, j in zip(plt.rcParams['axes.prop_cycle'], range(nb_samples)):
6667
ax.add_patch(plt.Circle(prng.normal(scale=3, size=2),
6768
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+
6877
# Force the limits to be the same across the styles (because different
6978
# styles may have different numbers of available colors).
7079
ax.set_xlim([-4, 8])
@@ -110,7 +119,7 @@ def plot_figure(style_label=""):
110119
prng = np.random.RandomState(96917002)
111120

112121
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)
114123

115124
# make a suptitle, in the same style for all subfigures,
116125
# except those with dark backgrounds, which get a lighter color:
@@ -126,9 +135,18 @@ def plot_figure(style_label=""):
126135
plot_scatter(axs[0], prng)
127136
plot_image_and_patch(axs[1], prng)
128137
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)
132150

133151

134152
if __name__ == "__main__":

0 commit comments

Comments
 (0)