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

Skip to content

Commit 488dc9c

Browse files
authored
Merge pull request #13915 from meeseeksmachine/auto-backport-of-pr-13835-on-v3.1.x
Backport PR #13835 on branch v3.1.x (Improve Conectionstyle Demo)
2 parents d2930b4 + 0eed653 commit 488dc9c

File tree

2 files changed

+23
-11
lines changed

2 files changed

+23
-11
lines changed

.flake8

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ per-file-ignores =
257257
examples/user_interfaces/mpl_with_glade3_sgskip.py: E402
258258
examples/user_interfaces/pylab_with_gtk_sgskip.py: E302, E402
259259
examples/user_interfaces/toolmanager_sgskip.py: E402
260+
examples/userdemo/connectionstyle_demo.py: E402
260261
examples/userdemo/custom_boxstyle01.py: E402
261262
examples/userdemo/pgf_preamble_sgskip.py: E402
262263
examples/userdemo/simple_annotate01.py: E501

examples/userdemo/connectionstyle_demo.py

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,25 @@
33
Connectionstyle Demo
44
====================
55
6+
When creating an annotation using `~.Axes.annotate`, the arrow shape can be
7+
controlled via the *connectionstyle* parameter of *arrowprops*. For further
8+
details see the description of `.FancyArrowPatch`.
69
"""
710

811
import matplotlib.pyplot as plt
912

1013

11-
fig, axs = plt.subplots(3, 5, figsize=(8, 4.8))
12-
x1, y1 = 0.3, 0.3
13-
x2, y2 = 0.7, 0.7
14-
15-
16-
def demo_con_style(ax, connectionstyle, label=None):
14+
def demo_con_style(ax, connectionstyle):
1715
x1, y1 = 0.3, 0.2
1816
x2, y2 = 0.8, 0.6
1917

2018
ax.plot([x1, x2], [y1, y2], ".")
2119
ax.annotate("",
2220
xy=(x1, y1), xycoords='data',
2321
xytext=(x2, y2), textcoords='data',
24-
arrowprops=dict(arrowstyle="->",
25-
color="0.5",
22+
arrowprops=dict(arrowstyle="->", color="0.5",
2623
shrinkA=5, shrinkB=5,
27-
patchA=None,
28-
patchB=None,
24+
patchA=None, patchB=None,
2925
connectionstyle=connectionstyle,
3026
),
3127
)
@@ -34,6 +30,7 @@ def demo_con_style(ax, connectionstyle, label=None):
3430
transform=ax.transAxes, ha="left", va="top")
3531

3632

33+
fig, axs = plt.subplots(3, 5, figsize=(8, 4.8))
3734
demo_con_style(axs[0, 0], "angle3,angleA=90,angleB=0")
3835
demo_con_style(axs[1, 0], "angle3,angleA=0,angleB=90")
3936
demo_con_style(axs[0, 1], "arc3,rad=0.")
@@ -51,6 +48,20 @@ def demo_con_style(ax, connectionstyle, label=None):
5148

5249
for ax in axs.flat:
5350
ax.set(xlim=(0, 1), ylim=(0, 1), xticks=[], yticks=[], aspect=1)
54-
fig.tight_layout(pad=0)
51+
fig.tight_layout(pad=0.2)
5552

5653
plt.show()
54+
55+
#############################################################################
56+
#
57+
# ------------
58+
#
59+
# References
60+
# """"""""""
61+
#
62+
# The use of the following functions, methods, classes and modules is shown
63+
# in this example:
64+
65+
import matplotlib
66+
matplotlib.axes.Axes.annotate
67+
matplotlib.patches.FancyArrowPatch

0 commit comments

Comments
 (0)