passagemath-plot 10.6.31rc3__cp314-cp314-manylinux_2_27_aarch64.manylinux_2_28_aarch64.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 +81 -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.libs/libgfortran-e1b7dfc8.so.5.0.0 +0 -0
- passagemath_plot.libs/libgsl-e3525837.so.28.0.0 +0 -0
- passagemath_plot.libs/libopenblasp-r0-4c5b64b1.3.29.so +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-aarch64-linux-gnu.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-aarch64-linux-gnu.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-aarch64-linux-gnu.so +0 -0
- sage/plot/plot3d/implicit_surface.pyx +1453 -0
- sage/plot/plot3d/index_face_set.cpython-314-aarch64-linux-gnu.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-aarch64-linux-gnu.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-aarch64-linux-gnu.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-aarch64-linux-gnu.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/point.py
ADDED
|
@@ -0,0 +1,624 @@
|
|
|
1
|
+
# sage_setup: distribution = sagemath-plot
|
|
2
|
+
r"""
|
|
3
|
+
Points
|
|
4
|
+
|
|
5
|
+
TESTS::
|
|
6
|
+
|
|
7
|
+
sage: E = EllipticCurve('37a') # needs sage.schemes
|
|
8
|
+
sage: P = E(0,0) # needs sage.schemes
|
|
9
|
+
sage: def get_points(n):
|
|
10
|
+
....: return sum(point(list(i*P)[:2], size=3)
|
|
11
|
+
....: for i in range(-n,n) if i != 0 and (i*P)[0] < 3)
|
|
12
|
+
sage: sum(get_points(15*n).plot3d(z=n) for n in range(1,10)) # needs sage.schemes
|
|
13
|
+
Graphics3d Object
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
# ****************************************************************************
|
|
17
|
+
# Copyright (C) 2006 Alex Clemesha <clemesha@gmail.com>,
|
|
18
|
+
# William Stein <wstein@gmail.com>,
|
|
19
|
+
# 2008 Mike Hansen <mhansen@gmail.com>,
|
|
20
|
+
#
|
|
21
|
+
# This program is free software: you can redistribute it and/or modify
|
|
22
|
+
# it under the terms of the GNU General Public License as published by
|
|
23
|
+
# the Free Software Foundation, either version 2 of the License, or
|
|
24
|
+
# (at your option) any later version.
|
|
25
|
+
# https://www.gnu.org/licenses/
|
|
26
|
+
# ****************************************************************************
|
|
27
|
+
|
|
28
|
+
from sage.misc.decorators import options, rename_keyword
|
|
29
|
+
from sage.plot.colors import to_mpl_color
|
|
30
|
+
from sage.plot.primitive import GraphicPrimitive_xydata
|
|
31
|
+
from collections.abc import Iterator
|
|
32
|
+
import numbers
|
|
33
|
+
|
|
34
|
+
# TODO: create _allowed_options for 3D point classes to
|
|
35
|
+
# improve bad option handling in plot3d?
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class Point(GraphicPrimitive_xydata):
|
|
39
|
+
"""
|
|
40
|
+
Primitive class for the point graphics type. See point?, point2d?
|
|
41
|
+
or point3d? for information about actually plotting points.
|
|
42
|
+
|
|
43
|
+
INPUT:
|
|
44
|
+
|
|
45
|
+
- ``xdata`` -- list of x values for points in Point object
|
|
46
|
+
|
|
47
|
+
- ``ydata`` -- list of y values for points in Point object
|
|
48
|
+
|
|
49
|
+
- ``options`` -- dictionary of valid plot options to pass to constructor
|
|
50
|
+
|
|
51
|
+
EXAMPLES:
|
|
52
|
+
|
|
53
|
+
Note this should normally be used indirectly via :func:`point` and friends::
|
|
54
|
+
|
|
55
|
+
sage: from sage.plot.point import Point
|
|
56
|
+
sage: P = Point([1,2],[2,3],{'alpha':.5})
|
|
57
|
+
sage: P
|
|
58
|
+
Point set defined by 2 point(s)
|
|
59
|
+
sage: P.options()['alpha']
|
|
60
|
+
0.500000000000000
|
|
61
|
+
sage: P.xdata
|
|
62
|
+
[1, 2]
|
|
63
|
+
|
|
64
|
+
TESTS:
|
|
65
|
+
|
|
66
|
+
We test creating a point::
|
|
67
|
+
|
|
68
|
+
sage: point((3,3))
|
|
69
|
+
Graphics object consisting of 1 graphics primitive
|
|
70
|
+
"""
|
|
71
|
+
def __init__(self, xdata, ydata, options):
|
|
72
|
+
"""
|
|
73
|
+
Initialize base class Point.
|
|
74
|
+
|
|
75
|
+
EXAMPLES::
|
|
76
|
+
|
|
77
|
+
sage: P = point((3,4))
|
|
78
|
+
sage: P[0].xdata
|
|
79
|
+
[3.0]
|
|
80
|
+
sage: P[0].options()['alpha']
|
|
81
|
+
1
|
|
82
|
+
"""
|
|
83
|
+
self.xdata = xdata
|
|
84
|
+
self.ydata = ydata
|
|
85
|
+
GraphicPrimitive_xydata.__init__(self, options)
|
|
86
|
+
|
|
87
|
+
def _allowed_options(self):
|
|
88
|
+
"""
|
|
89
|
+
Return the allowed options for the Point class.
|
|
90
|
+
|
|
91
|
+
EXAMPLES::
|
|
92
|
+
|
|
93
|
+
sage: P = point((3,4))
|
|
94
|
+
sage: P[0]._allowed_options()['size']
|
|
95
|
+
'How big the point is (i.e., area in points^2=(1/72 inch)^2).'
|
|
96
|
+
"""
|
|
97
|
+
return {'alpha': 'How transparent the point is.',
|
|
98
|
+
'faceted': 'If True color the edge of the point. (only for 2D plots)',
|
|
99
|
+
'hue': 'The color given as a hue.',
|
|
100
|
+
'legend_color': 'The color of the legend text',
|
|
101
|
+
'legend_label': 'The label for this item in the legend.',
|
|
102
|
+
'marker': 'the marker symbol for 2D plots only (see documentation of plot() for details)',
|
|
103
|
+
'markeredgecolor': 'the color of the marker edge (only for 2D plots)',
|
|
104
|
+
'rgbcolor': 'The color as an RGB tuple.',
|
|
105
|
+
'size': 'How big the point is (i.e., area in points^2=(1/72 inch)^2).',
|
|
106
|
+
'zorder': 'The layer level in which to draw'}
|
|
107
|
+
|
|
108
|
+
def _plot3d_options(self, options=None):
|
|
109
|
+
"""
|
|
110
|
+
Translate 2D plot options into 3D plot options.
|
|
111
|
+
|
|
112
|
+
EXAMPLES::
|
|
113
|
+
|
|
114
|
+
sage: A = point((1,1),size=22)
|
|
115
|
+
sage: a = A[0]; a
|
|
116
|
+
Point set defined by 1 point(s)
|
|
117
|
+
sage: b = a.plot3d()
|
|
118
|
+
sage: b.size
|
|
119
|
+
22
|
|
120
|
+
sage: b = a.plot3d(size=3)
|
|
121
|
+
sage: b.size
|
|
122
|
+
3
|
|
123
|
+
"""
|
|
124
|
+
if options is None:
|
|
125
|
+
options = dict(self.options())
|
|
126
|
+
options_3d = {}
|
|
127
|
+
if 'size' in options:
|
|
128
|
+
options_3d['size'] = options['size']
|
|
129
|
+
del options['size']
|
|
130
|
+
if options.pop('faceted', False):
|
|
131
|
+
raise NotImplementedError("3D points cannot be faceted")
|
|
132
|
+
for o in ('marker', 'markeredgecolor'): # remove 2D options
|
|
133
|
+
if o in options:
|
|
134
|
+
del options[o]
|
|
135
|
+
|
|
136
|
+
options_3d.update(GraphicPrimitive_xydata._plot3d_options(self, options))
|
|
137
|
+
return options_3d
|
|
138
|
+
|
|
139
|
+
def plot3d(self, z=0, **kwds):
|
|
140
|
+
"""
|
|
141
|
+
Plots a two-dimensional point in 3-D, with default height zero.
|
|
142
|
+
|
|
143
|
+
INPUT:
|
|
144
|
+
|
|
145
|
+
- ``z`` -- (optional) 3D height above `xy`-plane; may be a list
|
|
146
|
+
if ``self`` is a list of points
|
|
147
|
+
|
|
148
|
+
EXAMPLES:
|
|
149
|
+
|
|
150
|
+
One point::
|
|
151
|
+
|
|
152
|
+
sage: A = point((1, 1))
|
|
153
|
+
sage: a = A[0]; a
|
|
154
|
+
Point set defined by 1 point(s)
|
|
155
|
+
sage: b = a.plot3d()
|
|
156
|
+
|
|
157
|
+
.. PLOT::
|
|
158
|
+
|
|
159
|
+
A = point((1, 1))
|
|
160
|
+
a = A[0]
|
|
161
|
+
sphinx_plot(a.plot3d())
|
|
162
|
+
|
|
163
|
+
One point with a height::
|
|
164
|
+
|
|
165
|
+
sage: A = point((1, 1))
|
|
166
|
+
sage: a = A[0]; a
|
|
167
|
+
Point set defined by 1 point(s)
|
|
168
|
+
sage: b = a.plot3d(z=3)
|
|
169
|
+
sage: b.loc[2]
|
|
170
|
+
3.0
|
|
171
|
+
|
|
172
|
+
.. PLOT::
|
|
173
|
+
|
|
174
|
+
A = point((1, 1))
|
|
175
|
+
a = A[0]
|
|
176
|
+
sphinx_plot(a.plot3d(z=3))
|
|
177
|
+
|
|
178
|
+
Multiple points::
|
|
179
|
+
|
|
180
|
+
sage: P = point([(0, 0), (1, 1)])
|
|
181
|
+
sage: p = P[0]; p
|
|
182
|
+
Point set defined by 2 point(s)
|
|
183
|
+
sage: q = p.plot3d(size=22)
|
|
184
|
+
|
|
185
|
+
.. PLOT::
|
|
186
|
+
|
|
187
|
+
P = point([(0, 0), (1, 1)])
|
|
188
|
+
p = P[0]
|
|
189
|
+
sphinx_plot(p.plot3d(size=22))
|
|
190
|
+
|
|
191
|
+
Multiple points with different heights::
|
|
192
|
+
|
|
193
|
+
sage: P = point([(0, 0), (1, 1)])
|
|
194
|
+
sage: p = P[0]
|
|
195
|
+
sage: q = p.plot3d(z=[2,3])
|
|
196
|
+
sage: q.all[0].loc[2]
|
|
197
|
+
2.0
|
|
198
|
+
sage: q.all[1].loc[2]
|
|
199
|
+
3.0
|
|
200
|
+
|
|
201
|
+
.. PLOT::
|
|
202
|
+
|
|
203
|
+
P = point([(0, 0), (1, 1)])
|
|
204
|
+
p = P[0]
|
|
205
|
+
sphinx_plot(p.plot3d(z=[2,3]))
|
|
206
|
+
|
|
207
|
+
Note that keywords passed must be valid point3d options::
|
|
208
|
+
|
|
209
|
+
sage: A = point((1, 1), size=22)
|
|
210
|
+
sage: a = A[0]; a
|
|
211
|
+
Point set defined by 1 point(s)
|
|
212
|
+
sage: b = a.plot3d()
|
|
213
|
+
sage: b.size
|
|
214
|
+
22
|
|
215
|
+
sage: b = a.plot3d(pointsize=23) # only 2D valid option
|
|
216
|
+
sage: b.size
|
|
217
|
+
22
|
|
218
|
+
sage: b = a.plot3d(size=23) # correct keyword
|
|
219
|
+
sage: b.size
|
|
220
|
+
23
|
|
221
|
+
|
|
222
|
+
TESTS:
|
|
223
|
+
|
|
224
|
+
Heights passed as a list should have same length as
|
|
225
|
+
number of points::
|
|
226
|
+
|
|
227
|
+
sage: P = point([(0, 0), (1, 1), (2, 3)])
|
|
228
|
+
sage: p = P[0]
|
|
229
|
+
sage: q = p.plot3d(z=2)
|
|
230
|
+
sage: q.all[1].loc[2]
|
|
231
|
+
2.0
|
|
232
|
+
sage: q = p.plot3d(z=[2,-2])
|
|
233
|
+
Traceback (most recent call last):
|
|
234
|
+
...
|
|
235
|
+
ValueError: incorrect number of heights given
|
|
236
|
+
"""
|
|
237
|
+
from sage.plot.plot3d.base import Graphics3dGroup
|
|
238
|
+
from sage.plot.plot3d.shapes2 import point3d
|
|
239
|
+
options = self._plot3d_options()
|
|
240
|
+
options.update(kwds)
|
|
241
|
+
zdata = []
|
|
242
|
+
if isinstance(z, list):
|
|
243
|
+
zdata = z
|
|
244
|
+
else:
|
|
245
|
+
zdata = [z] * len(self.xdata)
|
|
246
|
+
if len(zdata) == len(self.xdata):
|
|
247
|
+
all = [point3d(list(zip(self.xdata, self.ydata, zdata)), **options)]
|
|
248
|
+
if len(all) == 1:
|
|
249
|
+
return all[0]
|
|
250
|
+
else:
|
|
251
|
+
return Graphics3dGroup(all)
|
|
252
|
+
else:
|
|
253
|
+
raise ValueError('incorrect number of heights given')
|
|
254
|
+
|
|
255
|
+
def _repr_(self):
|
|
256
|
+
"""
|
|
257
|
+
String representation of Point primitive.
|
|
258
|
+
|
|
259
|
+
EXAMPLES::
|
|
260
|
+
|
|
261
|
+
sage: P = point([(0, 0), (1, 1)])
|
|
262
|
+
sage: p = P[0]; p
|
|
263
|
+
Point set defined by 2 point(s)
|
|
264
|
+
"""
|
|
265
|
+
return "Point set defined by %s point(s)" % len(self.xdata)
|
|
266
|
+
|
|
267
|
+
def __getitem__(self, i):
|
|
268
|
+
"""
|
|
269
|
+
Return tuple of coordinates of point.
|
|
270
|
+
|
|
271
|
+
EXAMPLES::
|
|
272
|
+
|
|
273
|
+
sage: P = point([(0, 0), (1, 1), (2, 3)])
|
|
274
|
+
sage: p = P[0]; p
|
|
275
|
+
Point set defined by 3 point(s)
|
|
276
|
+
sage: p[1]
|
|
277
|
+
(1.0, 1.0)
|
|
278
|
+
"""
|
|
279
|
+
return self.xdata[i], self.ydata[i]
|
|
280
|
+
|
|
281
|
+
def _render_on_subplot(self, subplot):
|
|
282
|
+
r"""
|
|
283
|
+
TESTS:
|
|
284
|
+
|
|
285
|
+
We check to make sure that :issue:`2076` is fixed by verifying all
|
|
286
|
+
the points are red::
|
|
287
|
+
|
|
288
|
+
sage: point(((1, 1), (2, 2), (3, 3)), rgbcolor=hue(1), size=30)
|
|
289
|
+
Graphics object consisting of 1 graphics primitive
|
|
290
|
+
"""
|
|
291
|
+
options = self.options()
|
|
292
|
+
|
|
293
|
+
# Convert the color to a hex string so that the scatter
|
|
294
|
+
# method does not interpret it as a list of 3 floating
|
|
295
|
+
# point color specifications when there are
|
|
296
|
+
# three points. This is mentioned in the matplotlib 0.98
|
|
297
|
+
# documentation and fixes #2076
|
|
298
|
+
from matplotlib.colors import rgb2hex
|
|
299
|
+
c = rgb2hex(to_mpl_color(options['rgbcolor']))
|
|
300
|
+
|
|
301
|
+
a = float(options['alpha'])
|
|
302
|
+
z = int(options.pop('zorder', 0))
|
|
303
|
+
s = int(options['size'])
|
|
304
|
+
faceted = options['faceted'] # faceted=True colors the edge of point
|
|
305
|
+
markeredgecolor = options['markeredgecolor']
|
|
306
|
+
|
|
307
|
+
scatteroptions = {}
|
|
308
|
+
if not faceted and markeredgecolor is None:
|
|
309
|
+
scatteroptions['edgecolors'] = 'none'
|
|
310
|
+
elif markeredgecolor is not None:
|
|
311
|
+
scatteroptions['edgecolors'] = to_mpl_color(
|
|
312
|
+
options.pop('markeredgecolor'))
|
|
313
|
+
scatteroptions['marker'] = options.pop('marker')
|
|
314
|
+
|
|
315
|
+
subplot.scatter(self.xdata, self.ydata, s=s, c=c, alpha=a, zorder=z,
|
|
316
|
+
label=options['legend_label'], **scatteroptions)
|
|
317
|
+
|
|
318
|
+
|
|
319
|
+
def point(points, **kwds):
|
|
320
|
+
"""
|
|
321
|
+
Return either a 2-dimensional or 3-dimensional point or sum of points.
|
|
322
|
+
|
|
323
|
+
INPUT:
|
|
324
|
+
|
|
325
|
+
- ``points`` -- either a single point (as a tuple), a list of
|
|
326
|
+
points, a single complex number, or a list of complex numbers
|
|
327
|
+
|
|
328
|
+
For information regarding additional arguments, see either point2d?
|
|
329
|
+
or point3d?.
|
|
330
|
+
|
|
331
|
+
.. SEEALSO::
|
|
332
|
+
|
|
333
|
+
:func:`sage.plot.point.point2d`, :func:`sage.plot.plot3d.shapes2.point3d`
|
|
334
|
+
|
|
335
|
+
EXAMPLES::
|
|
336
|
+
|
|
337
|
+
sage: point((1, 2))
|
|
338
|
+
Graphics object consisting of 1 graphics primitive
|
|
339
|
+
|
|
340
|
+
.. PLOT::
|
|
341
|
+
|
|
342
|
+
sphinx_plot(point((1, 2)))
|
|
343
|
+
|
|
344
|
+
::
|
|
345
|
+
|
|
346
|
+
sage: point((1, 2, 3))
|
|
347
|
+
Graphics3d Object
|
|
348
|
+
|
|
349
|
+
.. PLOT::
|
|
350
|
+
|
|
351
|
+
sphinx_plot(point((1, 2, 3)))
|
|
352
|
+
|
|
353
|
+
::
|
|
354
|
+
|
|
355
|
+
sage: point([(0, 0), (1, 1)])
|
|
356
|
+
Graphics object consisting of 1 graphics primitive
|
|
357
|
+
|
|
358
|
+
.. PLOT::
|
|
359
|
+
|
|
360
|
+
sphinx_plot(point([(0, 0), (1, 1)]))
|
|
361
|
+
|
|
362
|
+
::
|
|
363
|
+
|
|
364
|
+
sage: point([(0, 0, 1), (1, 1, 1)])
|
|
365
|
+
Graphics3d Object
|
|
366
|
+
|
|
367
|
+
.. PLOT::
|
|
368
|
+
|
|
369
|
+
sphinx_plot(point([(0, 0, 1), (1, 1, 1)]))
|
|
370
|
+
|
|
371
|
+
Extra options will get passed on to show(), as long as they are valid::
|
|
372
|
+
|
|
373
|
+
sage: point([(cos(theta), sin(theta)) # needs sage.symbolic
|
|
374
|
+
....: for theta in srange(0, 2*pi, pi/8)], frame=True)
|
|
375
|
+
Graphics object consisting of 1 graphics primitive
|
|
376
|
+
sage: point([(cos(theta), sin(theta)) # These are equivalent # needs sage.symbolic
|
|
377
|
+
....: for theta in srange(0, 2*pi, pi/8)]).show(frame=True)
|
|
378
|
+
|
|
379
|
+
TESTS:
|
|
380
|
+
|
|
381
|
+
One can now use iterators (:issue:`13890`)::
|
|
382
|
+
|
|
383
|
+
sage: point(iter([(1, 1, 1)]))
|
|
384
|
+
Graphics3d Object
|
|
385
|
+
sage: point(iter([(1, 2), (3, 5)]))
|
|
386
|
+
Graphics object consisting of 1 graphics primitive
|
|
387
|
+
"""
|
|
388
|
+
if isinstance(points, Iterator):
|
|
389
|
+
points = list(points)
|
|
390
|
+
|
|
391
|
+
try:
|
|
392
|
+
return point2d(points, **kwds)
|
|
393
|
+
except (ValueError, TypeError):
|
|
394
|
+
from sage.plot.plot3d.shapes2 import point3d
|
|
395
|
+
return point3d(points, **kwds)
|
|
396
|
+
|
|
397
|
+
|
|
398
|
+
@rename_keyword(color='rgbcolor', pointsize='size')
|
|
399
|
+
@options(alpha=1, aspect_ratio='automatic', faceted=False,
|
|
400
|
+
legend_color=None, legend_label=None, marker='o',
|
|
401
|
+
markeredgecolor=None, rgbcolor=(0, 0, 1), size=10)
|
|
402
|
+
def point2d(points, **options):
|
|
403
|
+
r"""
|
|
404
|
+
A point of size ``size`` defined by point = `(x, y)`.
|
|
405
|
+
|
|
406
|
+
INPUT:
|
|
407
|
+
|
|
408
|
+
- ``points`` -- either a single point (as a tuple), a list of
|
|
409
|
+
points, a single complex number, or a list of complex numbers
|
|
410
|
+
|
|
411
|
+
- ``alpha`` -- how transparent the point is
|
|
412
|
+
|
|
413
|
+
- ``faceted`` -- if ``True``, color the edge of the point (only for 2D plots)
|
|
414
|
+
|
|
415
|
+
- ``hue`` -- the color given as a hue
|
|
416
|
+
|
|
417
|
+
- ``legend_color`` -- the color of the legend text
|
|
418
|
+
|
|
419
|
+
- ``legend_label`` -- the label for this item in the legend
|
|
420
|
+
|
|
421
|
+
- ``marker`` -- the marker symbol for 2D plots only (see documentation of
|
|
422
|
+
:func:`plot` for details)
|
|
423
|
+
|
|
424
|
+
- ``markeredgecolor`` -- the color of the marker edge (only for 2D plots)
|
|
425
|
+
|
|
426
|
+
- ``rgbcolor`` -- the color as an RGB tuple
|
|
427
|
+
|
|
428
|
+
- ``size`` -- how big the point is (i.e., area in points^2=(1/72 inch)^2)
|
|
429
|
+
|
|
430
|
+
- ``zorder`` -- the layer level in which to draw
|
|
431
|
+
|
|
432
|
+
EXAMPLES:
|
|
433
|
+
|
|
434
|
+
A purple point from a single tuple of coordinates::
|
|
435
|
+
|
|
436
|
+
sage: point((0.5, 0.5), rgbcolor=hue(0.75))
|
|
437
|
+
Graphics object consisting of 1 graphics primitive
|
|
438
|
+
|
|
439
|
+
.. PLOT::
|
|
440
|
+
|
|
441
|
+
sphinx_plot(point((0.5, 0.5), rgbcolor=hue(0.75)))
|
|
442
|
+
|
|
443
|
+
Points with customized markers and edge colors::
|
|
444
|
+
|
|
445
|
+
sage: r = [(random(), random()) for _ in range(10)]
|
|
446
|
+
sage: point(r, marker='d', markeredgecolor='red', size=20)
|
|
447
|
+
Graphics object consisting of 1 graphics primitive
|
|
448
|
+
|
|
449
|
+
.. PLOT::
|
|
450
|
+
|
|
451
|
+
r = [(random(), random()) for _ in range(10)]
|
|
452
|
+
sphinx_plot(point(r, marker='d', markeredgecolor='red', size=20))
|
|
453
|
+
|
|
454
|
+
Passing an empty list returns an empty plot::
|
|
455
|
+
|
|
456
|
+
sage: point([])
|
|
457
|
+
Graphics object consisting of 0 graphics primitives
|
|
458
|
+
sage: import numpy; point(numpy.array([]))
|
|
459
|
+
Graphics object consisting of 0 graphics primitives
|
|
460
|
+
|
|
461
|
+
If you need a 2D point to live in 3-space later, this is possible::
|
|
462
|
+
|
|
463
|
+
sage: A = point((1, 1))
|
|
464
|
+
sage: a = A[0]; a
|
|
465
|
+
Point set defined by 1 point(s)
|
|
466
|
+
sage: b = a.plot3d(z=3)
|
|
467
|
+
|
|
468
|
+
.. PLOT::
|
|
469
|
+
|
|
470
|
+
A = point((1, 1))
|
|
471
|
+
a = A[0]
|
|
472
|
+
b = a.plot3d(z=3)
|
|
473
|
+
sphinx_plot(b)
|
|
474
|
+
|
|
475
|
+
This is also true with multiple points::
|
|
476
|
+
|
|
477
|
+
sage: P = point([(0, 0), (1, 1)])
|
|
478
|
+
sage: p = P[0]
|
|
479
|
+
sage: q = p.plot3d(z=[2,3])
|
|
480
|
+
|
|
481
|
+
.. PLOT::
|
|
482
|
+
|
|
483
|
+
P = point([(0, 0), (1, 1)])
|
|
484
|
+
p = P[0]
|
|
485
|
+
q = p.plot3d(z=[2,3])
|
|
486
|
+
sphinx_plot(q)
|
|
487
|
+
|
|
488
|
+
Here are some random larger red points, given as a list of tuples::
|
|
489
|
+
|
|
490
|
+
sage: point(((0.5, 0.5), (1, 2), (0.5, 0.9), (-1, -1)), rgbcolor=hue(1), size=30)
|
|
491
|
+
Graphics object consisting of 1 graphics primitive
|
|
492
|
+
|
|
493
|
+
.. PLOT::
|
|
494
|
+
|
|
495
|
+
sphinx_plot(point(((0.5, 0.5), (1, 2), (0.5, 0.9), (-1, -1)), rgbcolor=hue(1), size=30))
|
|
496
|
+
|
|
497
|
+
And an example with a legend::
|
|
498
|
+
|
|
499
|
+
sage: point((0, 0), rgbcolor='black', pointsize=40, legend_label='origin')
|
|
500
|
+
Graphics object consisting of 1 graphics primitive
|
|
501
|
+
|
|
502
|
+
.. PLOT::
|
|
503
|
+
|
|
504
|
+
sphinx_plot(point((0, 0), rgbcolor='black', pointsize=40, legend_label='origin'))
|
|
505
|
+
|
|
506
|
+
The legend can be colored::
|
|
507
|
+
|
|
508
|
+
sage: P = points([(0, 0), (1, 0)], pointsize=40,
|
|
509
|
+
....: legend_label='origin', legend_color='red')
|
|
510
|
+
sage: P + plot(x^2, (x, 0, 1), legend_label='plot', legend_color='green') # needs sage.symbolic
|
|
511
|
+
Graphics object consisting of 2 graphics primitives
|
|
512
|
+
|
|
513
|
+
.. PLOT::
|
|
514
|
+
|
|
515
|
+
P = points([(0, 0), (1, 0)], pointsize=40, legend_label='origin', legend_color='red')
|
|
516
|
+
Q = P + plot(x**2, (x, 0, 1), legend_label='plot', legend_color='green')
|
|
517
|
+
sphinx_plot(Q)
|
|
518
|
+
|
|
519
|
+
Extra options will get passed on to show(), as long as they are valid::
|
|
520
|
+
|
|
521
|
+
sage: point([(cos(theta), sin(theta)) # needs sage.symbolic
|
|
522
|
+
....: for theta in srange(0, 2*pi, pi/8)], frame=True)
|
|
523
|
+
Graphics object consisting of 1 graphics primitive
|
|
524
|
+
sage: point([(cos(theta), sin(theta)) # These are equivalent # needs sage.symbolic
|
|
525
|
+
....: for theta in srange(0, 2*pi, pi/8)]).show(frame=True)
|
|
526
|
+
|
|
527
|
+
.. PLOT::
|
|
528
|
+
|
|
529
|
+
sphinx_plot(point([(cos(theta), sin(theta)) for theta in srange(0, 2*pi, pi/8)], frame=True))
|
|
530
|
+
|
|
531
|
+
For plotting data, we can use a logarithmic scale, as long as we are sure
|
|
532
|
+
not to include any nonpositive points in the logarithmic direction::
|
|
533
|
+
|
|
534
|
+
sage: point([(1, 2),(2, 4),(3, 4),(4, 8),(4.5, 32)], scale='semilogy', base=2)
|
|
535
|
+
Graphics object consisting of 1 graphics primitive
|
|
536
|
+
|
|
537
|
+
.. PLOT::
|
|
538
|
+
|
|
539
|
+
sphinx_plot(point([(1, 2),(2, 4),(3, 4),(4, 8),(4.5, 32)], scale='semilogy', base=2))
|
|
540
|
+
|
|
541
|
+
Since Sage Version 4.4 (:issue:`8599`), the size of a 2d point can be
|
|
542
|
+
given by the argument ``size`` instead of ``pointsize``. The argument
|
|
543
|
+
``pointsize`` is still supported::
|
|
544
|
+
|
|
545
|
+
sage: point((3, 4), size=100)
|
|
546
|
+
Graphics object consisting of 1 graphics primitive
|
|
547
|
+
|
|
548
|
+
::
|
|
549
|
+
|
|
550
|
+
sage: point((3, 4), pointsize=100)
|
|
551
|
+
Graphics object consisting of 1 graphics primitive
|
|
552
|
+
|
|
553
|
+
We can plot a single complex number::
|
|
554
|
+
|
|
555
|
+
sage: point(1 + I, pointsize=100) # needs sage.symbolic
|
|
556
|
+
Graphics object consisting of 1 graphics primitive
|
|
557
|
+
sage: point(sqrt(2) + I, pointsize=100) # needs sage.symbolic
|
|
558
|
+
Graphics object consisting of 1 graphics primitive
|
|
559
|
+
|
|
560
|
+
.. PLOT::
|
|
561
|
+
|
|
562
|
+
sphinx_plot(point(1 + I, pointsize=100))
|
|
563
|
+
|
|
564
|
+
.. PLOT::
|
|
565
|
+
|
|
566
|
+
sphinx_plot(point(sqrt(2) + I, pointsize=100))
|
|
567
|
+
|
|
568
|
+
We can also plot a list of complex numbers::
|
|
569
|
+
|
|
570
|
+
sage: point([I, 1 + I, 2 + 2*I], pointsize=100) # needs sage.symbolic
|
|
571
|
+
Graphics object consisting of 1 graphics primitive
|
|
572
|
+
|
|
573
|
+
.. PLOT::
|
|
574
|
+
|
|
575
|
+
sphinx_plot(point([I, 1 + I, 2 + 2*I], pointsize=100))
|
|
576
|
+
|
|
577
|
+
TESTS::
|
|
578
|
+
|
|
579
|
+
sage: point2d(iter([]))
|
|
580
|
+
Graphics object consisting of 0 graphics primitives
|
|
581
|
+
|
|
582
|
+
Verify that :issue:`36153` does not arise::
|
|
583
|
+
|
|
584
|
+
sage: P = point((0.5, 0.5), legend_label='test')
|
|
585
|
+
"""
|
|
586
|
+
from sage.plot.plot import xydata_from_point_list
|
|
587
|
+
from sage.plot.all import Graphics
|
|
588
|
+
from sage.structure.element import Expression
|
|
589
|
+
|
|
590
|
+
# points could be a single number
|
|
591
|
+
if isinstance(points, numbers.Complex):
|
|
592
|
+
points = [(points.real(), points.imag())]
|
|
593
|
+
elif isinstance(points, numbers.Real):
|
|
594
|
+
points = [points]
|
|
595
|
+
elif isinstance(points, Expression):
|
|
596
|
+
points = [points]
|
|
597
|
+
elif not isinstance(points, (list, tuple)): # or an iterator
|
|
598
|
+
points = list(points)
|
|
599
|
+
|
|
600
|
+
l = len(points)
|
|
601
|
+
if l == 0:
|
|
602
|
+
return Graphics()
|
|
603
|
+
elif l == 2: # special case for a single 2D point
|
|
604
|
+
if all(isinstance(z, numbers.Real)
|
|
605
|
+
or (isinstance(z, Expression) and not complex(z).imag)
|
|
606
|
+
for z in points):
|
|
607
|
+
points = [points]
|
|
608
|
+
elif l == 3: # special case for a single 3D point
|
|
609
|
+
if all(isinstance(z, numbers.Real)
|
|
610
|
+
or (isinstance(z, Expression) and not complex(z).imag)
|
|
611
|
+
for z in points):
|
|
612
|
+
raise TypeError('not a 2D point')
|
|
613
|
+
|
|
614
|
+
xdata, ydata = xydata_from_point_list(points)
|
|
615
|
+
g = Graphics()
|
|
616
|
+
g._set_extra_kwds(Graphics._extract_kwds_for_show(options))
|
|
617
|
+
g.add_primitive(Point(xdata, ydata, options))
|
|
618
|
+
if options['legend_label']:
|
|
619
|
+
g.legend(True)
|
|
620
|
+
g._legend_colors = [options['legend_color']]
|
|
621
|
+
return g
|
|
622
|
+
|
|
623
|
+
|
|
624
|
+
points = point
|