8000 changes as recommended · matplotlib/matplotlib@d2e6e92 · GitHub
[go: up one dir, main page]

Skip to content

Commit d2e6e92

Browse files
committed
changes as recommended
1 parent 318ff59 commit d2e6e92

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

examples/lines_bars_and_markers/linestyles.py

Lines changed: 16 additions & 11 deletions
< 4C6F td data-grid-cell-id="diff-041eebd43c7b2000464be5bac9713d4900eb40c4dfb173880c3c37ebf3317e98-64-68-0" data-selected="false" role="gridcell" style="background-color:var(--diffBlob-additionNum-bgColor, var(--diffBlob-addition-bgColor-num));text-align:center" tabindex="-1" valign="top" class="focusable-grid-cell diff-line-number position-relative left-side">
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
Linestyles
44
==========
55
6-
Linestyle can be provided as simple as *solid* , *dotted*, *dashed*
7-
or *dashdot*. Moreover, the dashing of the line can be controlled by
8-
a dash tuple such as (offset, (on_off_seq)) as mentioned in
9-
`.Line2D.set_linestyle`. For example, ``(0, (3, 10, 1, 15))`` means
10-
3pt-line,10pt-space,1pt-line,15pt-space with no offset.
6+
Simple linestyles can be defined using the strings "solid", "dotted", "dashed"
7+
or "dashdot". More refined control can be achieved by providing a dash tuple
8+
``(offset, (on_off_seq))``. For example, ``(0, (3, 10, 1, 15))`` means
9< 10000 code class="diff-text syntax-highlighted-line addition">+
(3pt line, 10pt space, 1pt line, 15pt space) with no offset. See also
10+
`.Line2D.set_linestyle`.
1111
1212
*Note*: The dash style can also be configured via `.Line2D.set_dashes`
1313
as shown in :doc:`/gallery/lines_bars_and_markers/line_demo_dash_control`
@@ -26,21 +26,26 @@
2626

2727
linestyle_tuple = [
2828
('loosely dotted', (0, (1, 10))),
29+
('dotted', (0, (1, 1))),
2930
('densely dotted', (0, (1, 1))),
3031

3132
('loosely dashed', (0, (5, 10))),
33+
('dashed', (0, (5, 5))),
3234
('densely dashed', (0, (5, 1))),
3335

3436
('loosely dashdotted', (0, (3, 10, 1, 10))),
37+
('dashdotted', (0, (3, 5, 1, 5))),
3538
('densely dashdotted', (0, (3, 1, 1, 1))),
3639

3740
('dashdotdotted', (0, (3, 5, 1, 5, 1, 5))),
3841
('loosely dashdotdotted', (0, (3, 10, 1, 10, 1, 10))),
3942
('densely dashdotdotted', (0, (3, 1, 1, 1, 1, 1)))]
4043

4144

42-
def simple_plot(ax, linestyles):
45+
def plot_linestyles(ax, linestyles):
46+
X, Y = np.linspace(0, 100, 10), np.zeros(10)
4347
yticklabels = []
48+
4449
for i, (name, linestyle) in enumerate(linestyles):
4550
ax.plot(X, Y+i, linestyle=linestyle, linewidth=1.5, color='black')
4651
yticklabels.append(name)
@@ -56,12 +61,12 @@ def simple_plot(ax, linestyles):
5661
xytext=(-6, -12), textcoords='offset points', color="blue",
5762
fontsize=8, ha="right", family="monospace")
5863

59-
X, Y = np.linspace(0, 100, 10), np.zeros(10)
60-
fig, ax = plt.subplots(2, 1, gridspec_kw={'height_ratios': [1, 2]},
61-
figsize=(10, 6))
6264

63-
simple_plot(ax[0], linestyle_str[::-1])
64-
simple_plot(ax[1], linestyle_tuple[::-1])
65+
fig, (ax0, ax1) = plt.subplots(2, 1, gridspec_kw={'height_ratios': [1, 3]},
66+
figsize=(10, 8))
67+
68+
plot_linestyles(ax0, linestyle_str[::-1])
69+
plot_linestyles(ax1, linestyle_tuple[::-1])
6570

6671
plt.tight_layout()
6772
plt.show()

0 commit comments

Comments
 (0)
0