8000 combine two examples into one · matplotlib/matplotlib@8d5340e · GitHub
[go: up one dir, main page]

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 8d5340e

Browse files
committed
combine two examples into one
1 parent 36bc620 commit 8d5340e

File tree

2 files changed

+22
-33
lines changed

2 files changed

+22
-33
lines changed

examples/lines_bars_and_markers/line_styles_reference.py

Lines changed: 0 additions & 24 deletions
This file was deleted.

examples/lines_bars_and_markers/linestyles.py

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,44 @@
33
Linestyles
44
==========
55
6-
This examples showcases different linestyles copying those of Tikz/PGF.
6+
This example showcases different linestyles copying those of Tikz/PGF.
7+
Linestyle can be provided as simple as *solid* , *dotted* or *dashed*.
8+
Moreover, the dashing of the line can be controlled by a dash tuple
9+
such as (offset, (on_off_seq)) as mentioned in `.Line2D.set_linestyle`.
10+
For e.g., ``(0, (3, 10, 1, 15))`` means 3pt-line,10pt-space,1pt-line,15pt-space
11+
with no offset.
12+
13+
*Note*: The dash style can also be configured via `.Line2D.set_dashes`
14+
as shown in :doc:`/gallery/lines_bars_and_markers/line_demo_dash_control`
15+
and passing a list of dash sequences using the keyword *dashes* to the
16+
cycler in :doc:`property_cycle </tutorials/intermediate/color_cycle>`.
717
"""
818
import numpy as np
919
import matplotlib.pyplot as plt
1020
from collections import OrderedDict
1121
from matplotlib.transforms import blended_transform_factory
1222

13-
linestyles = OrderedDict(
14-
[('solid', (0, ())),
23+
linestyles = [
24+
('solid', ('-')), # Same as (0, ())
25+
('dotted', (':')), # Same as (0, (1, 1))
26+
('dashed', ('--')),
27+
('dashdot', ('-.')),
28+
1529
('loosely dotted', (0, (1, 10))),
16-
('dotted', (0, (1, 5))),
1730
('densely dotted', (0, (1, 1))),
1831

1932
('loosely dashed', (0, (5, 10))),
20-
('dashed', (0, (5, 5))),
2133
('densely dashed', (0, (5, 1))),
2234

2335
('loosely dashdotted', (0, (3, 10, 1, 10))),
24-
('dashdotted', (0, (3, 5, 1, 5))),
2536
('densely dashdotted', (0, (3, 1, 1, 1))),
2637

38+
('dashdotdotted', (0, (3, 5, 1, 5, 1, 5))),
2739
('loosely dashdotdotted', (0, (3, 10, 1, 10, 1, 10))),
28-
('dashdotdotted', (0, (3, 5, 1, 5, 1, 5))),
29-
('densely dashdotdotted', (0, (3, 1, 1, 1, 1, 1)))])
40+
('densely dashdotdotted', (0, (3, 1, 1, 1, 1, 1)))]
3041

42+
# Reverse the list so that plots and linestyles are in same order.
43+
linestyles = OrderedDict(linestyles[::-1])
3144

3245
plt.figure(figsize=(10, 6))
3346
ax = plt.subplot(1, 1, 1)
@@ -44,7 +57,7 @@
4457
# the reference point (0 in Axes coords, y tick value in Data coords).
4558
reference_transform = blended_transform_factory(ax.transAxes, ax.transData)
4659
for i, (name, linestyle) in enumerate(linestyles.items()):
47-
ax.annotate(str(linestyle), xy=(0.0, i), xycoords=reference_transform,
60+
ax.annotate(repr(linestyle), xy=(0.0, i), xycoords=reference_transform,
4861
xytext=(-6, -12), textcoords='offset points', color="blue",
4962
fontsize=8, ha="right", family="monospace")
5063

0 commit comments

Comments
 (0)
0