Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d2e6e92

Browse filesBrowse files
committed
changes as recommended
1 parent 318ff59 commit d2e6e92
Copy full SHA for d2e6e92

File tree

Expand file treeCollapse file tree

1 file changed

+16
-11
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+16
-11
lines changed

‎examples/lines_bars_and_markers/linestyles.py

Copy file name to clipboardExpand all lines: examples/lines_bars_and_markers/linestyles.py
+16-11Lines changed: 16 additions & 11 deletions
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+
(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)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.