Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit363bc5e

Browse files
committed
Rename angle marker example to angle annotation.
1 parent1e5f172 commit363bc5e

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

‎examples/lines_bars_and_markers/angle_marker.pyrenamed to‎examples/text_labels_and_annotations/angle_annotation.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
2-
============================
3-
Scale invariant anglemarker
4-
============================
2+
===========================
3+
Scale invariant anglelabel
4+
===========================
55
66
This example shows how to create a scale invariant angle marker. It is often
77
useful to mark angles between lines or inside shapes with a circular arc. While
@@ -14,7 +14,7 @@
1414
1515
This calls for a solution where the arc's center is defined in data space, but
1616
its radius in a physical unit like points or pixels, or as a ratio of the Axes
17-
dimension. The following ``AngleMarker`` class provides such solution.
17+
dimension. The following ``AngleAnnotation`` class provides such solution.
1818
1919
The example below serves two purposes:
2020
@@ -29,8 +29,8 @@
2929
"""
3030

3131
#########################################################################
32-
#AngleMarker class
33-
# ~~~~~~~~~~~~~~~~~
32+
#AngleAnnotation class
33+
# ~~~~~~~~~~~~~~~~~~~~~
3434
# The essential idea here is to subclass `~.patches.Arc` and set its transform
3535
# to the `~.transforms.IdentityTransform`, making the parameters of the arc
3636
# defined in pixel space.
@@ -64,7 +64,7 @@
6464
frommatplotlib.transformsimportIdentityTransform,TransformedBbox,Bbox
6565

6666

67-
classAngleMarker(Arc):
67+
classAngleAnnotation(Arc):
6868
"""
6969
Draws an arc between two vectors which appears circular in display space.
7070
"""
@@ -218,9 +218,9 @@ def R(a, r, w, h):
218218
# Usage
219219
# ~~~~~
220220
#
221-
# Required arguments to ``AngleMarker`` are the center of the arc, *xy*, and
222-
# two points, such that the arc spans between the two vectors connecting *p1*
223-
# and *p2* with *xy*, respectively. Those are given in data coordinates.
221+
# Required arguments to ``AngleAnnotation`` are the center of the arc, *xy*,
222+
#andtwo points, such that the arc spans between the two vectors connecting
223+
#*p1*and *p2* with *xy*, respectively. Those are given in data coordinates.
224224
# Further arguments are the *size* of the arc and its *unit*. Additionally, a
225225
# *text* can be specified, that will be drawn either in- or outside of the arc,
226226
# according to the value of *textposition*. Usage of those arguments is shown
@@ -233,27 +233,27 @@ def R(a, r, w, h):
233233
fig.canvas.draw()# Need to draw the figure to define renderer
234234

235235
#### SUBPLOT 1 ####
236-
# Plot two crossing lines and label each angle between them with the
237-
#above `AngleMarker`tool.
236+
# Plot two crossing lines and label each angle between them with the above
237+
#``AngleAnnotation``tool.
238238
center= (4.5,650)
239239
p1= [(2.5,710), (6.0,605)]
240240
p2= [(3.0,275), (5.5,900)]
241241
line1,=ax1.plot(*zip(*p1))
242242
line2,=ax1.plot(*zip(*p2))
243243
point,=ax1.plot(*center,marker="o")
244244

245-
am1=AngleMarker(center,p1[1],p2[1],ax=ax1,size=75,text=r"$\alpha$")
246-
am2=AngleMarker(center,p2[1],p1[0],ax=ax1,size=35,text=r"$\beta$")
247-
am3=AngleMarker(center,p1[0],p2[0],ax=ax1,size=75,text=r"$\gamma$")
248-
am4=AngleMarker(center,p2[0],p1[1],ax=ax1,size=35,text=r"$\theta$")
245+
am1=AngleAnnotation(center,p1[1],p2[1],ax=ax1,size=75,text=r"$\alpha$")
246+
am2=AngleAnnotation(center,p2[1],p1[0],ax=ax1,size=35,text=r"$\beta$")
247+
am3=AngleAnnotation(center,p1[0],p2[0],ax=ax1,size=75,text=r"$\gamma$")
248+
am4=AngleAnnotation(center,p2[0],p1[1],ax=ax1,size=35,text=r"$\theta$")
249249

250250

251251
# Showcase some styling options for the angle arc, as well as the text.
252252
p= [(6.0,400), (5.3,410), (5.6,300)]
253253
ax1.plot(*zip(*p))
254-
am5=AngleMarker(p[1],p[0],p[2],ax=ax1,size=40,text=r"$\Phi$",
255-
linestyle="--",color="gray",textposition="outside",
256-
text_kw=dict(fontsize=16,color="gray"))
254+
am5=AngleAnnotation(p[1],p[0],p[2],ax=ax1,size=40,text=r"$\Phi$",
255+
linestyle="--",color="gray",textposition="outside",
256+
text_kw=dict(fontsize=16,color="gray"))
257257

258258

259259
#### SUBPLOT 2 ####
@@ -262,7 +262,7 @@ def plot_angle(ax, pos, angle, length=0.95, acol="C0", **kwargs):
262262
vec2=np.array([np.cos(np.deg2rad(angle)),np.sin(np.deg2rad(angle))])
263263
xy=np.c_[[length,0], [0,0],vec2*length].T+np.array(pos)
264264
ax.plot(*xy.T,color=acol)
265-
returnAngleMarker(pos,xy[0],xy[2],ax=ax,**kwargs)
265+
returnAngleAnnotation(pos,xy[0],xy[2],ax=ax,**kwargs)
266266

267267
# Showcase different text positions.
268268
kw=dict(size=75,unit="points",text=r"$60°$")

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp