passagemath-plot 10.6.31rc3__cp314-cp314-macosx_13_0_arm64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of passagemath-plot might be problematic. Click here for more details.
- passagemath_plot-10.6.31rc3.dist-info/METADATA +172 -0
- passagemath_plot-10.6.31rc3.dist-info/RECORD +82 -0
- passagemath_plot-10.6.31rc3.dist-info/WHEEL +6 -0
- passagemath_plot-10.6.31rc3.dist-info/top_level.txt +2 -0
- passagemath_plot.dylibs/libgfortran.5.dylib +0 -0
- passagemath_plot.dylibs/libgsl.28.dylib +0 -0
- passagemath_plot.dylibs/libopenblasp-r0.3.29.dylib +0 -0
- passagemath_plot.dylibs/libquadmath.0.dylib +0 -0
- sage/all__sagemath_plot.py +15 -0
- sage/ext_data/threejs/animation.css +195 -0
- sage/ext_data/threejs/animation.html +85 -0
- sage/ext_data/threejs/animation.js +273 -0
- sage/ext_data/threejs/fat_lines.js +48 -0
- sage/ext_data/threejs/threejs-version.txt +1 -0
- sage/ext_data/threejs/threejs_template.html +597 -0
- sage/interfaces/all__sagemath_plot.py +1 -0
- sage/interfaces/gnuplot.py +196 -0
- sage/interfaces/jmoldata.py +208 -0
- sage/interfaces/povray.py +56 -0
- sage/plot/all.py +42 -0
- sage/plot/animate.py +1796 -0
- sage/plot/arc.py +504 -0
- sage/plot/arrow.py +671 -0
- sage/plot/bar_chart.py +205 -0
- sage/plot/bezier_path.py +400 -0
- sage/plot/circle.py +435 -0
- sage/plot/colors.py +1606 -0
- sage/plot/complex_plot.cpython-314-darwin.so +0 -0
- sage/plot/complex_plot.pyx +1446 -0
- sage/plot/contour_plot.py +1792 -0
- sage/plot/density_plot.py +318 -0
- sage/plot/disk.py +373 -0
- sage/plot/ellipse.py +375 -0
- sage/plot/graphics.py +3580 -0
- sage/plot/histogram.py +354 -0
- sage/plot/hyperbolic_arc.py +404 -0
- sage/plot/hyperbolic_polygon.py +416 -0
- sage/plot/hyperbolic_regular_polygon.py +296 -0
- sage/plot/line.py +626 -0
- sage/plot/matrix_plot.py +629 -0
- sage/plot/misc.py +509 -0
- sage/plot/multigraphics.py +1294 -0
- sage/plot/plot.py +4183 -0
- sage/plot/plot3d/all.py +23 -0
- sage/plot/plot3d/base.cpython-314-darwin.so +0 -0
- sage/plot/plot3d/base.pxd +12 -0
- sage/plot/plot3d/base.pyx +3378 -0
- sage/plot/plot3d/implicit_plot3d.py +659 -0
- sage/plot/plot3d/implicit_surface.cpython-314-darwin.so +0 -0
- sage/plot/plot3d/implicit_surface.pyx +1453 -0
- sage/plot/plot3d/index_face_set.cpython-314-darwin.so +0 -0
- sage/plot/plot3d/index_face_set.pxd +32 -0
- sage/plot/plot3d/index_face_set.pyx +1873 -0
- sage/plot/plot3d/introduction.py +131 -0
- sage/plot/plot3d/list_plot3d.py +649 -0
- sage/plot/plot3d/parametric_plot3d.py +1130 -0
- sage/plot/plot3d/parametric_surface.cpython-314-darwin.so +0 -0
- sage/plot/plot3d/parametric_surface.pxd +12 -0
- sage/plot/plot3d/parametric_surface.pyx +893 -0
- sage/plot/plot3d/platonic.py +601 -0
- sage/plot/plot3d/plot3d.py +1442 -0
- sage/plot/plot3d/plot_field3d.py +162 -0
- sage/plot/plot3d/point_c.pxi +148 -0
- sage/plot/plot3d/revolution_plot3d.py +309 -0
- sage/plot/plot3d/shapes.cpython-314-darwin.so +0 -0
- sage/plot/plot3d/shapes.pxd +22 -0
- sage/plot/plot3d/shapes.pyx +1382 -0
- sage/plot/plot3d/shapes2.py +1512 -0
- sage/plot/plot3d/tachyon.py +1779 -0
- sage/plot/plot3d/texture.py +453 -0
- sage/plot/plot3d/transform.cpython-314-darwin.so +0 -0
- sage/plot/plot3d/transform.pxd +21 -0
- sage/plot/plot3d/transform.pyx +268 -0
- sage/plot/plot3d/tri_plot.py +589 -0
- sage/plot/plot_field.py +362 -0
- sage/plot/point.py +624 -0
- sage/plot/polygon.py +562 -0
- sage/plot/primitive.py +249 -0
- sage/plot/scatter_plot.py +199 -0
- sage/plot/step.py +85 -0
- sage/plot/streamline_plot.py +328 -0
- sage/plot/text.py +432 -0
sage/plot/arc.py
ADDED
|
@@ -0,0 +1,504 @@
|
|
|
1
|
+
# sage_setup: distribution = sagemath-plot
|
|
2
|
+
"""
|
|
3
|
+
Arcs of circles and ellipses
|
|
4
|
+
"""
|
|
5
|
+
# ****************************************************************************
|
|
6
|
+
# Copyright (C) 2010 Vincent Delecroix <20100.delecroix@gmail.com>,
|
|
7
|
+
#
|
|
8
|
+
# Distributed under the terms of the GNU General Public License (GPL)
|
|
9
|
+
#
|
|
10
|
+
# This code is distributed in the hope that it will be useful,
|
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
13
|
+
# General Public License for more details.
|
|
14
|
+
#
|
|
15
|
+
# The full text of the GPL is available at:
|
|
16
|
+
#
|
|
17
|
+
# https://www.gnu.org/licenses/
|
|
18
|
+
# ****************************************************************************
|
|
19
|
+
|
|
20
|
+
from sage.plot.primitive import GraphicPrimitive
|
|
21
|
+
from sage.plot.colors import to_mpl_color
|
|
22
|
+
|
|
23
|
+
from sage.misc.decorators import options, rename_keyword
|
|
24
|
+
|
|
25
|
+
from math import fmod, sin, cos, pi, atan
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class Arc(GraphicPrimitive):
|
|
29
|
+
"""
|
|
30
|
+
Primitive class for the Arc graphics type. See ``arc?`` for information
|
|
31
|
+
about actually plotting an arc of a circle or an ellipse.
|
|
32
|
+
|
|
33
|
+
INPUT:
|
|
34
|
+
|
|
35
|
+
- ``x``, ``y`` -- coordinates of the center of the arc
|
|
36
|
+
|
|
37
|
+
- ``r1``, ``r2`` -- lengths of the two radii
|
|
38
|
+
|
|
39
|
+
- ``angle`` -- angle of the horizontal with width
|
|
40
|
+
|
|
41
|
+
- ``sector`` -- sector of angle
|
|
42
|
+
|
|
43
|
+
- ``options`` -- dictionary of valid plot options to pass to constructor
|
|
44
|
+
|
|
45
|
+
EXAMPLES:
|
|
46
|
+
|
|
47
|
+
Note that the construction should be done using ``arc``::
|
|
48
|
+
|
|
49
|
+
sage: from math import pi
|
|
50
|
+
sage: from sage.plot.arc import Arc
|
|
51
|
+
sage: print(Arc(0,0,1,1,pi/4,pi/4,pi/2,{}))
|
|
52
|
+
Arc with center (0.0,0.0) radii (1.0,1.0) angle 0.78539816339... inside the sector (0.78539816339...,1.5707963267...)
|
|
53
|
+
"""
|
|
54
|
+
def __init__(self, x, y, r1, r2, angle, s1, s2, options):
|
|
55
|
+
"""
|
|
56
|
+
Initialize base class ``Arc``.
|
|
57
|
+
|
|
58
|
+
EXAMPLES::
|
|
59
|
+
|
|
60
|
+
sage: # needs sage.symbolic
|
|
61
|
+
sage: A = arc((2,3),1,1,pi/4,(0,pi))
|
|
62
|
+
sage: A[0].x == 2
|
|
63
|
+
True
|
|
64
|
+
sage: A[0].y == 3
|
|
65
|
+
True
|
|
66
|
+
sage: A[0].r1 == 1
|
|
67
|
+
True
|
|
68
|
+
sage: A[0].r2 == 1
|
|
69
|
+
True
|
|
70
|
+
sage: A[0].angle
|
|
71
|
+
0.7853981633974483
|
|
72
|
+
sage: bool(A[0].s1 == 0)
|
|
73
|
+
True
|
|
74
|
+
sage: A[0].s2
|
|
75
|
+
3.141592653589793
|
|
76
|
+
|
|
77
|
+
TESTS::
|
|
78
|
+
|
|
79
|
+
sage: from sage.plot.arc import Arc
|
|
80
|
+
sage: a = Arc(0,0,1,1,0,0,1,{})
|
|
81
|
+
sage: print(loads(dumps(a)))
|
|
82
|
+
Arc with center (0.0,0.0) radii (1.0,1.0) angle 0.0 inside the sector (0.0,1.0)
|
|
83
|
+
"""
|
|
84
|
+
self.x = float(x)
|
|
85
|
+
self.y = float(y)
|
|
86
|
+
self.r1 = float(r1)
|
|
87
|
+
self.r2 = float(r2)
|
|
88
|
+
if self.r1 <= 0 or self.r2 <= 0:
|
|
89
|
+
raise ValueError("the radii must be positive real numbers")
|
|
90
|
+
|
|
91
|
+
self.angle = float(angle)
|
|
92
|
+
self.s1 = float(s1)
|
|
93
|
+
self.s2 = float(s2)
|
|
94
|
+
if self.s2 < self.s1:
|
|
95
|
+
self.s1, self.s2 = self.s2, self.s1
|
|
96
|
+
GraphicPrimitive.__init__(self, options)
|
|
97
|
+
|
|
98
|
+
def get_minmax_data(self):
|
|
99
|
+
r"""
|
|
100
|
+
Return a dictionary with the bounding box data.
|
|
101
|
+
|
|
102
|
+
The bounding box is computed as minimal as possible.
|
|
103
|
+
|
|
104
|
+
EXAMPLES:
|
|
105
|
+
|
|
106
|
+
An example without angle::
|
|
107
|
+
|
|
108
|
+
sage: p = arc((-2, 3), 1, 2)
|
|
109
|
+
sage: d = p.get_minmax_data()
|
|
110
|
+
sage: d['xmin']
|
|
111
|
+
-3.0
|
|
112
|
+
sage: d['xmax']
|
|
113
|
+
-1.0
|
|
114
|
+
sage: d['ymin']
|
|
115
|
+
1.0
|
|
116
|
+
sage: d['ymax']
|
|
117
|
+
5.0
|
|
118
|
+
|
|
119
|
+
The same example with a rotation of angle `\pi/2`::
|
|
120
|
+
|
|
121
|
+
sage: from math import pi
|
|
122
|
+
sage: p = arc((-2, 3), 1, 2, pi/2)
|
|
123
|
+
sage: d = p.get_minmax_data()
|
|
124
|
+
sage: d['xmin']
|
|
125
|
+
-4.0
|
|
126
|
+
sage: d['xmax']
|
|
127
|
+
0.0
|
|
128
|
+
sage: d['ymin']
|
|
129
|
+
2.0
|
|
130
|
+
sage: d['ymax']
|
|
131
|
+
4.0
|
|
132
|
+
"""
|
|
133
|
+
from sage.plot.plot import minmax_data
|
|
134
|
+
|
|
135
|
+
twopi = 2 * pi
|
|
136
|
+
|
|
137
|
+
s1 = self.s1
|
|
138
|
+
s2 = self.s2
|
|
139
|
+
s = s2 - s1
|
|
140
|
+
s1 = fmod(s1, twopi)
|
|
141
|
+
if s1 < 0:
|
|
142
|
+
s1 += twopi
|
|
143
|
+
s2 = fmod(s1 + s, twopi)
|
|
144
|
+
if s2 < 0:
|
|
145
|
+
s2 += twopi
|
|
146
|
+
|
|
147
|
+
r1 = self.r1
|
|
148
|
+
r2 = self.r2
|
|
149
|
+
|
|
150
|
+
angle = fmod(self.angle, twopi)
|
|
151
|
+
if angle < 0:
|
|
152
|
+
angle += twopi
|
|
153
|
+
|
|
154
|
+
epsilon = 0.0000001
|
|
155
|
+
|
|
156
|
+
cos_angle = cos(angle)
|
|
157
|
+
sin_angle = sin(angle)
|
|
158
|
+
|
|
159
|
+
if cos_angle > 1 - epsilon:
|
|
160
|
+
xmin = -r1
|
|
161
|
+
ymin = -r2
|
|
162
|
+
xmax = r1
|
|
163
|
+
ymax = r2
|
|
164
|
+
axmin = pi
|
|
165
|
+
axmax = 0
|
|
166
|
+
aymin = 3 * pi / 2
|
|
167
|
+
aymax = pi / 2
|
|
168
|
+
|
|
169
|
+
elif cos_angle < -1 + epsilon:
|
|
170
|
+
xmin = -r1
|
|
171
|
+
ymin = -r2
|
|
172
|
+
xmax = r1
|
|
173
|
+
ymax = r2
|
|
174
|
+
axmin = 0
|
|
175
|
+
axmax = pi
|
|
176
|
+
aymin = pi / 2
|
|
177
|
+
aymax = 3 * pi / 2
|
|
178
|
+
|
|
179
|
+
elif sin_angle > 1 - epsilon:
|
|
180
|
+
xmin = -r2
|
|
181
|
+
ymin = -r1
|
|
182
|
+
xmax = r2
|
|
183
|
+
ymax = r1
|
|
184
|
+
axmin = pi / 2
|
|
185
|
+
axmax = 3 * pi / 2
|
|
186
|
+
aymin = pi
|
|
187
|
+
aymax = 0
|
|
188
|
+
|
|
189
|
+
elif sin_angle < -1 + epsilon:
|
|
190
|
+
xmin = -r2
|
|
191
|
+
ymin = -r1
|
|
192
|
+
xmax = r2
|
|
193
|
+
ymax = r1
|
|
194
|
+
axmin = 3 * pi / 2
|
|
195
|
+
axmax = pi / 2
|
|
196
|
+
aymin = 0
|
|
197
|
+
aymax = pi
|
|
198
|
+
|
|
199
|
+
else:
|
|
200
|
+
tan_angle = sin_angle / cos_angle
|
|
201
|
+
axmax = atan(-r2 / r1 * tan_angle)
|
|
202
|
+
if axmax < 0:
|
|
203
|
+
axmax += twopi
|
|
204
|
+
xmax = (r1 * cos_angle * cos(axmax) -
|
|
205
|
+
r2 * sin_angle * sin(axmax))
|
|
206
|
+
if xmax < 0:
|
|
207
|
+
xmax = -xmax
|
|
208
|
+
axmax = fmod(axmax + pi, twopi)
|
|
209
|
+
xmin = -xmax
|
|
210
|
+
axmin = fmod(axmax + pi, twopi)
|
|
211
|
+
|
|
212
|
+
aymax = atan(r2 / (r1 * tan_angle))
|
|
213
|
+
if aymax < 0:
|
|
214
|
+
aymax += twopi
|
|
215
|
+
ymax = (r1 * sin_angle * cos(aymax) +
|
|
216
|
+
r2 * cos_angle * sin(aymax))
|
|
217
|
+
if ymax < 0:
|
|
218
|
+
ymax = -ymax
|
|
219
|
+
aymax = fmod(aymax + pi, twopi)
|
|
220
|
+
ymin = -ymax
|
|
221
|
+
aymin = fmod(aymax + pi, twopi)
|
|
222
|
+
|
|
223
|
+
if s < twopi - epsilon: # bb determined by the sector
|
|
224
|
+
def is_cyclic_ordered(x1, x2, x3):
|
|
225
|
+
return ((x1 < x2 < x3) or
|
|
226
|
+
(x2 < x3 < x1) or
|
|
227
|
+
(x3 < x1 < x2))
|
|
228
|
+
|
|
229
|
+
x1 = cos_angle * r1 * cos(s1) - sin_angle * r2 * sin(s1)
|
|
230
|
+
x2 = cos_angle * r1 * cos(s2) - sin_angle * r2 * sin(s2)
|
|
231
|
+
y1 = sin_angle * r1 * cos(s1) + cos_angle * r2 * sin(s1)
|
|
232
|
+
y2 = sin_angle * r1 * cos(s2) + cos_angle * r2 * sin(s2)
|
|
233
|
+
|
|
234
|
+
if is_cyclic_ordered(s1, s2, axmin):
|
|
235
|
+
xmin = min(x1, x2)
|
|
236
|
+
if is_cyclic_ordered(s1, s2, aymin):
|
|
237
|
+
ymin = min(y1, y2)
|
|
238
|
+
if is_cyclic_ordered(s1, s2, axmax):
|
|
239
|
+
xmax = max(x1, x2)
|
|
240
|
+
if is_cyclic_ordered(s1, s2, aymax):
|
|
241
|
+
ymax = max(y1, y2)
|
|
242
|
+
|
|
243
|
+
return minmax_data([self.x + xmin, self.x + xmax],
|
|
244
|
+
[self.y + ymin, self.y + ymax],
|
|
245
|
+
dict=True)
|
|
246
|
+
|
|
247
|
+
def _allowed_options(self):
|
|
248
|
+
"""
|
|
249
|
+
Return the allowed options for the ``Arc`` class.
|
|
250
|
+
|
|
251
|
+
EXAMPLES::
|
|
252
|
+
|
|
253
|
+
sage: p = arc((3, 3), 1, 1)
|
|
254
|
+
sage: p[0]._allowed_options()['alpha']
|
|
255
|
+
'How transparent the figure is.'
|
|
256
|
+
"""
|
|
257
|
+
return {'alpha': 'How transparent the figure is.',
|
|
258
|
+
'thickness': 'How thick the border of the arc is.',
|
|
259
|
+
'hue': 'The color given as a hue.',
|
|
260
|
+
'rgbcolor': 'The color',
|
|
261
|
+
'zorder': '2D only: The layer level in which to draw',
|
|
262
|
+
'linestyle': "2D only: The style of the line, which is one of "
|
|
263
|
+
"'dashed', 'dotted', 'solid', 'dashdot', or '--', ':', '-', '-.', "
|
|
264
|
+
"respectively."}
|
|
265
|
+
|
|
266
|
+
def _matplotlib_arc(self):
|
|
267
|
+
"""
|
|
268
|
+
Return ``self`` as a matplotlib arc object.
|
|
269
|
+
|
|
270
|
+
EXAMPLES::
|
|
271
|
+
|
|
272
|
+
sage: from sage.plot.arc import Arc
|
|
273
|
+
sage: Arc(2,3,2.2,2.2,0,2,3,{})._matplotlib_arc()
|
|
274
|
+
<matplotlib.patches.Arc object at ...>
|
|
275
|
+
"""
|
|
276
|
+
import matplotlib.patches as patches
|
|
277
|
+
p = patches.Arc((self.x, self.y),
|
|
278
|
+
2. * self.r1,
|
|
279
|
+
2. * self.r2,
|
|
280
|
+
angle=fmod(self.angle, 2 * pi) * (180. / pi),
|
|
281
|
+
theta1=self.s1 * (180. / pi),
|
|
282
|
+
theta2=self.s2 * (180. / pi))
|
|
283
|
+
return p
|
|
284
|
+
|
|
285
|
+
def bezier_path(self):
|
|
286
|
+
"""
|
|
287
|
+
Return ``self`` as a Bezier path.
|
|
288
|
+
|
|
289
|
+
This is needed to concatenate arcs, in order to
|
|
290
|
+
create hyperbolic polygons.
|
|
291
|
+
|
|
292
|
+
EXAMPLES::
|
|
293
|
+
|
|
294
|
+
sage: from sage.plot.arc import Arc
|
|
295
|
+
sage: op = {'alpha':1,'thickness':1,'rgbcolor':'blue','zorder':0,
|
|
296
|
+
....: 'linestyle':'--'}
|
|
297
|
+
sage: Arc(2,3,2.2,2.2,0,2,3,op).bezier_path()
|
|
298
|
+
Graphics object consisting of 1 graphics primitive
|
|
299
|
+
|
|
300
|
+
sage: from math import pi
|
|
301
|
+
sage: a = arc((0,0),2,1,0,(pi/5,pi/2+pi/12), linestyle='--', color='red')
|
|
302
|
+
sage: b = a[0].bezier_path()
|
|
303
|
+
sage: b[0]
|
|
304
|
+
Bezier path from (1.133..., 0.8237...) to (-0.2655..., 0.9911...)
|
|
305
|
+
"""
|
|
306
|
+
from sage.plot.bezier_path import BezierPath
|
|
307
|
+
from sage.plot.graphics import Graphics
|
|
308
|
+
from matplotlib.path import Path
|
|
309
|
+
import numpy as np
|
|
310
|
+
ma = self._matplotlib_arc()
|
|
311
|
+
|
|
312
|
+
def theta_stretch(theta, scale):
|
|
313
|
+
theta = np.deg2rad(theta)
|
|
314
|
+
x = np.cos(theta)
|
|
315
|
+
y = np.sin(theta)
|
|
316
|
+
return np.rad2deg(np.arctan2(scale * y, x))
|
|
317
|
+
theta1 = theta_stretch(ma.theta1, ma.width / ma.height)
|
|
318
|
+
theta2 = theta_stretch(ma.theta2, ma.width / ma.height)
|
|
319
|
+
|
|
320
|
+
pa = ma
|
|
321
|
+
pa._path = Path.arc(theta1, theta2)
|
|
322
|
+
transform = pa.get_transform().get_matrix()
|
|
323
|
+
cA, cC, cE = transform[0]
|
|
324
|
+
cB, cD, cF = transform[1]
|
|
325
|
+
points = []
|
|
326
|
+
for u in pa._path.vertices:
|
|
327
|
+
x, y = list(u)
|
|
328
|
+
points += [(cA * x + cC * y + cE, cB * x + cD * y + cF)]
|
|
329
|
+
cutlist = [points[0: 4]]
|
|
330
|
+
N = 4
|
|
331
|
+
while N < len(points):
|
|
332
|
+
cutlist += [points[N: N + 3]]
|
|
333
|
+
N += 3
|
|
334
|
+
g = Graphics()
|
|
335
|
+
opt = self.options()
|
|
336
|
+
opt['fill'] = False
|
|
337
|
+
g.add_primitive(BezierPath(cutlist, opt))
|
|
338
|
+
return g
|
|
339
|
+
|
|
340
|
+
def _repr_(self) -> str:
|
|
341
|
+
"""
|
|
342
|
+
String representation of ``Arc`` primitive.
|
|
343
|
+
|
|
344
|
+
EXAMPLES::
|
|
345
|
+
|
|
346
|
+
sage: from sage.plot.arc import Arc
|
|
347
|
+
sage: print(Arc(2,3,2.2,2.2,0,2,3,{}))
|
|
348
|
+
Arc with center (2.0,3.0) radii (2.2,2.2) angle 0.0 inside the sector (2.0,3.0)
|
|
349
|
+
"""
|
|
350
|
+
return f"Arc with center ({self.x},{self.y}) radii ({self.r1},{self.r2}) angle {self.angle} inside the sector ({self.s1},{self.s2})"
|
|
351
|
+
|
|
352
|
+
def _render_on_subplot(self, subplot):
|
|
353
|
+
"""
|
|
354
|
+
TESTS::
|
|
355
|
+
|
|
356
|
+
sage: from math import pi
|
|
357
|
+
sage: A = arc((1,1),3,4,pi/4,(pi,4*pi/3)); A
|
|
358
|
+
Graphics object consisting of 1 graphics primitive
|
|
359
|
+
"""
|
|
360
|
+
from sage.plot.misc import get_matplotlib_linestyle
|
|
361
|
+
|
|
362
|
+
options = self.options()
|
|
363
|
+
|
|
364
|
+
p = self._matplotlib_arc()
|
|
365
|
+
p.set_linewidth(float(options['thickness']))
|
|
366
|
+
a = float(options['alpha'])
|
|
367
|
+
p.set_alpha(a)
|
|
368
|
+
z = int(options.pop('zorder', 1))
|
|
369
|
+
p.set_zorder(z)
|
|
370
|
+
c = to_mpl_color(options['rgbcolor'])
|
|
371
|
+
p.set_linestyle(get_matplotlib_linestyle(options['linestyle'],
|
|
372
|
+
return_type='long'))
|
|
373
|
+
p.set_edgecolor(c)
|
|
374
|
+
subplot.add_patch(p)
|
|
375
|
+
|
|
376
|
+
def plot3d(self):
|
|
377
|
+
r"""
|
|
378
|
+
TESTS::
|
|
379
|
+
|
|
380
|
+
sage: from sage.plot.arc import Arc
|
|
381
|
+
sage: Arc(0,0,1,1,0,0,1,{}).plot3d()
|
|
382
|
+
Traceback (most recent call last):
|
|
383
|
+
...
|
|
384
|
+
NotImplementedError
|
|
385
|
+
"""
|
|
386
|
+
raise NotImplementedError
|
|
387
|
+
|
|
388
|
+
|
|
389
|
+
@rename_keyword(color='rgbcolor')
|
|
390
|
+
@options(alpha=1, thickness=1, linestyle='solid', zorder=5, rgbcolor='blue',
|
|
391
|
+
aspect_ratio=1.0)
|
|
392
|
+
def arc(center, r1, r2=None, angle=0.0, sector=(0.0, 2 * pi), **options):
|
|
393
|
+
r"""
|
|
394
|
+
An arc (that is a portion of a circle or an ellipse).
|
|
395
|
+
|
|
396
|
+
Type ``arc.options`` to see all options.
|
|
397
|
+
|
|
398
|
+
INPUT:
|
|
399
|
+
|
|
400
|
+
- ``center`` -- 2-tuple of real numbers; position of the center
|
|
401
|
+
|
|
402
|
+
- ``r1``, ``r2`` -- positive real numbers; radii of the ellipse. If only ``r1``
|
|
403
|
+
is set, then the two radii are supposed to be equal and this function returns
|
|
404
|
+
an arc of circle.
|
|
405
|
+
|
|
406
|
+
- ``angle`` -- real number; angle between the horizontal and the axis that
|
|
407
|
+
corresponds to ``r1``
|
|
408
|
+
|
|
409
|
+
- ``sector`` -- 2-tuple (default: (0,2*pi)); angles sector in which the arc will
|
|
410
|
+
be drawn
|
|
411
|
+
|
|
412
|
+
OPTIONS:
|
|
413
|
+
|
|
414
|
+
- ``alpha`` -- float (default: 1) -- transparency
|
|
415
|
+
|
|
416
|
+
- ``thickness`` -- float (default: 1) -- thickness of the arc
|
|
417
|
+
|
|
418
|
+
- ``color``, ``rgbcolor`` -- string or 2-tuple (default: ``'blue'``); the
|
|
419
|
+
color of the arc
|
|
420
|
+
|
|
421
|
+
- ``linestyle`` -- string (default: ``'solid'``); the style of the line,
|
|
422
|
+
which is one of ``'dashed'``, ``'dotted'``, ``'solid'``, ``'dashdot'``,
|
|
423
|
+
or ``'--'``, ``':'``, ``'-'``, ``'-.'``, respectively
|
|
424
|
+
|
|
425
|
+
EXAMPLES:
|
|
426
|
+
|
|
427
|
+
Plot an arc of circle centered at (0,0) with radius 1 in the sector
|
|
428
|
+
`(\pi/4,3*\pi/4)`::
|
|
429
|
+
|
|
430
|
+
sage: from math import pi
|
|
431
|
+
sage: arc((0,0), 1, sector=(pi/4,3*pi/4))
|
|
432
|
+
Graphics object consisting of 1 graphics primitive
|
|
433
|
+
|
|
434
|
+
.. PLOT::
|
|
435
|
+
|
|
436
|
+
sphinx_plot(arc((0,0), 1, sector=(pi/4,3*pi/4)))
|
|
437
|
+
|
|
438
|
+
Plot an arc of an ellipse between the angles 0 and `\pi/2`::
|
|
439
|
+
|
|
440
|
+
sage: arc((2,3), 2, 1, sector=(0,pi/2))
|
|
441
|
+
Graphics object consisting of 1 graphics primitive
|
|
442
|
+
|
|
443
|
+
.. PLOT::
|
|
444
|
+
|
|
445
|
+
sphinx_plot(arc((2,3), 2, 1, sector=(0,pi/2)))
|
|
446
|
+
|
|
447
|
+
Plot an arc of a rotated ellipse between the angles 0 and `\pi/2`::
|
|
448
|
+
|
|
449
|
+
sage: arc((2,3), 2, 1, angle=pi/5, sector=(0,pi/2))
|
|
450
|
+
Graphics object consisting of 1 graphics primitive
|
|
451
|
+
|
|
452
|
+
.. PLOT::
|
|
453
|
+
|
|
454
|
+
sphinx_plot(arc((2,3), 2, 1, angle=pi/5, sector=(0,pi/2)))
|
|
455
|
+
|
|
456
|
+
Plot an arc of an ellipse in red with a dashed linestyle::
|
|
457
|
+
|
|
458
|
+
sage: arc((0,0), 2, 1, 0, (0,pi/2), linestyle='dashed', color='red')
|
|
459
|
+
Graphics object consisting of 1 graphics primitive
|
|
460
|
+
sage: arc((0,0), 2, 1, 0, (0,pi/2), linestyle='--', color='red')
|
|
461
|
+
Graphics object consisting of 1 graphics primitive
|
|
462
|
+
|
|
463
|
+
.. PLOT::
|
|
464
|
+
|
|
465
|
+
sphinx_plot(arc((0,0), 2, 1, 0, (0,pi/2), linestyle='dashed', color='red'))
|
|
466
|
+
|
|
467
|
+
The default aspect ratio for arcs is 1.0::
|
|
468
|
+
|
|
469
|
+
sage: arc((0,0), 1, sector=(pi/4,3*pi/4)).aspect_ratio()
|
|
470
|
+
1.0
|
|
471
|
+
|
|
472
|
+
It is not possible to draw arcs in 3D::
|
|
473
|
+
|
|
474
|
+
sage: A = arc((0,0,0), 1)
|
|
475
|
+
Traceback (most recent call last):
|
|
476
|
+
...
|
|
477
|
+
NotImplementedError
|
|
478
|
+
"""
|
|
479
|
+
from sage.plot.all import Graphics
|
|
480
|
+
|
|
481
|
+
# Reset aspect_ratio to 'automatic' in case scale is 'semilog[xy]'.
|
|
482
|
+
# Otherwise matplotlib complains.
|
|
483
|
+
scale = options.get('scale', None)
|
|
484
|
+
if isinstance(scale, (list, tuple)):
|
|
485
|
+
scale = scale[0]
|
|
486
|
+
if scale == 'semilogy' or scale == 'semilogx':
|
|
487
|
+
options['aspect_ratio'] = 'automatic'
|
|
488
|
+
|
|
489
|
+
if len(center) == 2:
|
|
490
|
+
if r2 is None:
|
|
491
|
+
r2 = r1
|
|
492
|
+
g = Graphics()
|
|
493
|
+
g._set_extra_kwds(Graphics._extract_kwds_for_show(options))
|
|
494
|
+
if len(sector) != 2:
|
|
495
|
+
raise ValueError("the sector must consist of two angles")
|
|
496
|
+
g.add_primitive(Arc(
|
|
497
|
+
center[0], center[1],
|
|
498
|
+
r1, r2,
|
|
499
|
+
angle,
|
|
500
|
+
sector[0], sector[1],
|
|
501
|
+
options))
|
|
502
|
+
return g
|
|
503
|
+
elif len(center) == 3:
|
|
504
|
+
raise NotImplementedError
|