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

Skip to content

Commit d384595

Browse files
authored
Merge pull request #11909 from anntzer/styleref-docs
Simplify linestyle and fillstyle reference docs.
2 parents ebb6aa7 + 82bbe9c commit d384595

File tree

2 files changed

+16
-29
lines changed

2 files changed

+16
-29
lines changed

examples/lines_bars_and_markers/line_styles_reference.py

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,21 @@
55
66
Reference for line-styles included with Matplotlib.
77
"""
8+
89
import numpy as np
910
import matplotlib.pyplot as plt
1011

1112

12-
color = 'cornflowerblue'
13-
points = np.ones(5) # Draw 5 points for each line
14-
text_style = dict(horizontalalignment='right', verticalalignment='center',
15-
fontsize=12, fontdict={'family': 'monospace'})
16-
17-
18-
def format_axes(ax):
19-
ax.margins(0.2)
20-
ax.set_axis_off()
21-
22-
2313
# Plot all line styles.
2414
fig, ax = plt.subplots()
2515

2616
linestyles = ['-', '--', '-.', ':']
2717
for y, linestyle in enumerate(linestyles):
28-
ax.text(-0.1, y, repr(linestyle), **text_style)
29-
ax.plot(y * points, linestyle=linestyle, color=color, linewidth=3)
30-
format_axes(ax)
31-
ax.set_title('line styles')
18+
ax.text(-0.1, y, repr(linestyle),
19+
horizontalalignment='center', verticalalignment='center')
20+
ax.plot([y, y], linestyle=linestyle, linewidth=3, color='tab:blue')
21+
22+
ax.set_axis_off()
23+
ax.set_title('line styles')
3224

3325
plt.show()

examples/lines_bars_and_markers/marker_fillstyle_reference.py

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,25 @@
99
:doc:`/gallery/lines_bars_and_markers/marker_fillstyle_reference`
1010
and :doc:`/gallery/shapes_and_collections/marker_path` examples.
1111
"""
12+
1213
import numpy as np
1314
import matplotlib.pyplot as plt
1415
from matplotlib.lines import Line2D
1516

1617

17-
points = np.ones(5) # Draw 3 points for each line
18-
text_style = dict(horizontalalignment='right', verticalalignment='center',
19-
fontsize=12, fontdict={'family': 'monospace'})
20-
marker_style = dict(color='cornflowerblue', linestyle=':', marker='o',
21-
markersize=15, markerfacecoloralt='gray')
22-
23-
24-
def format_axes(ax):
25-
ax.margins(0.2)
26-
ax.set_axis_off()
27-
18+
points = np.ones(5) # Draw 5 points for each line
19+
marker_style = dict(color='tab:blue', linestyle=':', marker='o',
20+
markersize=15, markerfacecoloralt='tab:red')
2821

2922
fig, ax = plt.subplots()
3023

3124
# Plot all fill styles.
3225
for y, fill_style in enumerate(Line2D.fillStyles):
33-
ax.text(-0.5, y, repr(fill_style), **text_style)
26+
ax.text(-0.5, y, repr(fill_style),
27+
horizontalalignment='center', verticalalignment='center')
3428
ax.plot(y * points, fillstyle=fill_style, **marker_style)
35-
format_axes(ax)
36-
ax.set_title('fill style')
29+
30+
ax.set_axis_off()
31+
ax.set_title('fill style')
3732

3833
plt.show()

0 commit comments

Comments
 (0)