passagemath-plot 10.6.31rc3__cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.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.

Files changed (82) hide show
  1. passagemath_plot-10.6.31rc3.dist-info/METADATA +172 -0
  2. passagemath_plot-10.6.31rc3.dist-info/RECORD +82 -0
  3. passagemath_plot-10.6.31rc3.dist-info/WHEEL +6 -0
  4. passagemath_plot-10.6.31rc3.dist-info/top_level.txt +2 -0
  5. passagemath_plot.libs/libgfortran-83c28eba.so.5.0.0 +0 -0
  6. passagemath_plot.libs/libgsl-cda90e79.so.28.0.0 +0 -0
  7. passagemath_plot.libs/libopenblasp-r0-6dcb67f9.3.29.so +0 -0
  8. passagemath_plot.libs/libquadmath-2284e583.so.0.0.0 +0 -0
  9. sage/all__sagemath_plot.py +15 -0
  10. sage/ext_data/threejs/animation.css +195 -0
  11. sage/ext_data/threejs/animation.html +85 -0
  12. sage/ext_data/threejs/animation.js +273 -0
  13. sage/ext_data/threejs/fat_lines.js +48 -0
  14. sage/ext_data/threejs/threejs-version.txt +1 -0
  15. sage/ext_data/threejs/threejs_template.html +597 -0
  16. sage/interfaces/all__sagemath_plot.py +1 -0
  17. sage/interfaces/gnuplot.py +196 -0
  18. sage/interfaces/jmoldata.py +208 -0
  19. sage/interfaces/povray.py +56 -0
  20. sage/plot/all.py +42 -0
  21. sage/plot/animate.py +1796 -0
  22. sage/plot/arc.py +504 -0
  23. sage/plot/arrow.py +671 -0
  24. sage/plot/bar_chart.py +205 -0
  25. sage/plot/bezier_path.py +400 -0
  26. sage/plot/circle.py +435 -0
  27. sage/plot/colors.py +1606 -0
  28. sage/plot/complex_plot.cpython-314-x86_64-linux-gnu.so +0 -0
  29. sage/plot/complex_plot.pyx +1446 -0
  30. sage/plot/contour_plot.py +1792 -0
  31. sage/plot/density_plot.py +318 -0
  32. sage/plot/disk.py +373 -0
  33. sage/plot/ellipse.py +375 -0
  34. sage/plot/graphics.py +3580 -0
  35. sage/plot/histogram.py +354 -0
  36. sage/plot/hyperbolic_arc.py +404 -0
  37. sage/plot/hyperbolic_polygon.py +416 -0
  38. sage/plot/hyperbolic_regular_polygon.py +296 -0
  39. sage/plot/line.py +626 -0
  40. sage/plot/matrix_plot.py +629 -0
  41. sage/plot/misc.py +509 -0
  42. sage/plot/multigraphics.py +1294 -0
  43. sage/plot/plot.py +4183 -0
  44. sage/plot/plot3d/all.py +23 -0
  45. sage/plot/plot3d/base.cpython-314-x86_64-linux-gnu.so +0 -0
  46. sage/plot/plot3d/base.pxd +12 -0
  47. sage/plot/plot3d/base.pyx +3378 -0
  48. sage/plot/plot3d/implicit_plot3d.py +659 -0
  49. sage/plot/plot3d/implicit_surface.cpython-314-x86_64-linux-gnu.so +0 -0
  50. sage/plot/plot3d/implicit_surface.pyx +1453 -0
  51. sage/plot/plot3d/index_face_set.cpython-314-x86_64-linux-gnu.so +0 -0
  52. sage/plot/plot3d/index_face_set.pxd +32 -0
  53. sage/plot/plot3d/index_face_set.pyx +1873 -0
  54. sage/plot/plot3d/introduction.py +131 -0
  55. sage/plot/plot3d/list_plot3d.py +649 -0
  56. sage/plot/plot3d/parametric_plot3d.py +1130 -0
  57. sage/plot/plot3d/parametric_surface.cpython-314-x86_64-linux-gnu.so +0 -0
  58. sage/plot/plot3d/parametric_surface.pxd +12 -0
  59. sage/plot/plot3d/parametric_surface.pyx +893 -0
  60. sage/plot/plot3d/platonic.py +601 -0
  61. sage/plot/plot3d/plot3d.py +1442 -0
  62. sage/plot/plot3d/plot_field3d.py +162 -0
  63. sage/plot/plot3d/point_c.pxi +148 -0
  64. sage/plot/plot3d/revolution_plot3d.py +309 -0
  65. sage/plot/plot3d/shapes.cpython-314-x86_64-linux-gnu.so +0 -0
  66. sage/plot/plot3d/shapes.pxd +22 -0
  67. sage/plot/plot3d/shapes.pyx +1382 -0
  68. sage/plot/plot3d/shapes2.py +1512 -0
  69. sage/plot/plot3d/tachyon.py +1779 -0
  70. sage/plot/plot3d/texture.py +453 -0
  71. sage/plot/plot3d/transform.cpython-314-x86_64-linux-gnu.so +0 -0
  72. sage/plot/plot3d/transform.pxd +21 -0
  73. sage/plot/plot3d/transform.pyx +268 -0
  74. sage/plot/plot3d/tri_plot.py +589 -0
  75. sage/plot/plot_field.py +362 -0
  76. sage/plot/point.py +624 -0
  77. sage/plot/polygon.py +562 -0
  78. sage/plot/primitive.py +249 -0
  79. sage/plot/scatter_plot.py +199 -0
  80. sage/plot/step.py +85 -0
  81. sage/plot/streamline_plot.py +328 -0
  82. sage/plot/text.py +432 -0
sage/plot/polygon.py ADDED
@@ -0,0 +1,562 @@
1
+ # sage_setup: distribution = sagemath-plot
2
+ """
3
+ Polygons
4
+ """
5
+ # ****************************************************************************
6
+ # Copyright (C) 2006 Alex Clemesha <clemesha@gmail.com>,
7
+ # William Stein <wstein@gmail.com>,
8
+ # 2008 Mike Hansen <mhansen@gmail.com>,
9
+ #
10
+ # Distributed under the terms of the GNU General Public License (GPL)
11
+ #
12
+ # This code is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
+ # General Public License for more details.
16
+ #
17
+ # The full text of the GPL is available at:
18
+ #
19
+ # http://www.gnu.org/licenses/
20
+ # ****************************************************************************
21
+
22
+ from sage.plot.primitive import GraphicPrimitive_xydata
23
+ from sage.misc.decorators import options, rename_keyword
24
+ from sage.plot.colors import to_mpl_color
25
+
26
+
27
+ class Polygon(GraphicPrimitive_xydata):
28
+ """
29
+ Primitive class for the Polygon graphics type. For information
30
+ on actual plotting, please see :func:`polygon`, :func:`polygon2d`,
31
+ or :func:`~sage.plot.plot3d.shapes2.polygon3d`.
32
+
33
+ INPUT:
34
+
35
+ - ``xdata`` -- list of `x`-coordinates of points defining Polygon
36
+
37
+ - ``ydata`` -- list of `y`-coordinates of points defining Polygon
38
+
39
+ - ``options`` -- dictionary of valid plot options to pass to constructor
40
+
41
+ EXAMPLES:
42
+
43
+ Note this should normally be used indirectly via :func:`polygon`::
44
+
45
+ sage: from sage.plot.polygon import Polygon
46
+ sage: P = Polygon([1,2,3],[2,3,2],{'alpha':.5})
47
+ sage: P
48
+ Polygon defined by 3 points
49
+ sage: P.options()['alpha']
50
+ 0.500000000000000
51
+ sage: P.ydata
52
+ [2, 3, 2]
53
+
54
+ TESTS:
55
+
56
+ We test creating polygons::
57
+
58
+ sage: polygon([(0,0), (1,1), (0,1)])
59
+ Graphics object consisting of 1 graphics primitive
60
+
61
+ ::
62
+
63
+ sage: polygon([(0,0,1), (1,1,1), (2,0,1)])
64
+ Graphics3d Object
65
+
66
+ ::
67
+
68
+ sage: polygon2d([(1, 1), (0, 1), (1, 0)], fill=False, linestyle='dashed')
69
+ Graphics object consisting of 1 graphics primitive
70
+ """
71
+ def __init__(self, xdata, ydata, options):
72
+ """
73
+ Initialize base class Polygon.
74
+
75
+ EXAMPLES::
76
+
77
+ sage: P = polygon([(0,0), (1,1), (-1,3)], thickness=2)
78
+ sage: P[0].xdata
79
+ [0.0, 1.0, -1.0]
80
+ sage: P[0].options()['thickness']
81
+ 2
82
+ """
83
+ self.xdata = xdata
84
+ self.ydata = ydata
85
+ GraphicPrimitive_xydata.__init__(self, options)
86
+
87
+ def _repr_(self):
88
+ """
89
+ String representation of Polygon primitive.
90
+
91
+ EXAMPLES::
92
+
93
+ sage: P = polygon([(0,0), (1,1), (-1,3)])
94
+ sage: p=P[0]; p
95
+ Polygon defined by 3 points
96
+ """
97
+ return "Polygon defined by %s points" % len(self)
98
+
99
+ def __getitem__(self, i):
100
+ """
101
+ Return `i`-th vertex of Polygon primitive.
102
+
103
+ It is starting count from 0th vertex.
104
+
105
+ EXAMPLES::
106
+
107
+ sage: P = polygon([(0,0), (1,1), (-1,3)])
108
+ sage: p=P[0]
109
+ sage: p[0]
110
+ (0.0, 0.0)
111
+ """
112
+ return self.xdata[i], self.ydata[i]
113
+
114
+ def __setitem__(self, i, point):
115
+ """
116
+ Change `i`-th vertex of Polygon primitive.
117
+
118
+ It is starting count from 0th vertex.
119
+
120
+ Note that this only changes a vertex, but does not create new vertices.
121
+
122
+ EXAMPLES::
123
+
124
+ sage: P = polygon([(0,0), (1,2), (0,1), (-1,2)])
125
+ sage: p=P[0]
126
+ sage: [p[i] for i in range(4)]
127
+ [(0.0, 0.0), (1.0, 2.0), (0.0, 1.0), (-1.0, 2.0)]
128
+ sage: p[2]=(0,.5)
129
+ sage: p[2]
130
+ (0.0, 0.5)
131
+ """
132
+ i = int(i)
133
+ self.xdata[i] = float(point[0])
134
+ self.ydata[i] = float(point[1])
135
+
136
+ def __len__(self):
137
+ """
138
+ Return number of vertices of Polygon primitive.
139
+
140
+ EXAMPLES::
141
+
142
+ sage: P = polygon([(0,0), (1,2), (0,1), (-1,2)])
143
+ sage: p=P[0]
144
+ sage: len(p)
145
+ 4
146
+ """
147
+ return len(self.xdata)
148
+
149
+ def _allowed_options(self):
150
+ """
151
+ Return the allowed options for the Polygon class.
152
+
153
+ EXAMPLES::
154
+
155
+ sage: P = polygon([(1,1), (1,2), (2,2), (2,1)], alpha=.5)
156
+ sage: P[0]._allowed_options()['alpha']
157
+ 'How transparent the figure is.'
158
+ """
159
+ return {'alpha': 'How transparent the figure is.',
160
+ 'thickness': 'How thick the border line is.',
161
+ 'edgecolor': 'The color for the border of filled polygons.',
162
+ 'fill': 'Whether or not to fill the polygon.',
163
+ 'legend_label': 'The label for this item in the legend.',
164
+ 'legend_color': 'The color of the legend text.',
165
+ 'linestyle': 'The style of the enclosing line.',
166
+ 'rgbcolor': 'The color as an RGB tuple.',
167
+ 'hue': 'The color given as a hue.',
168
+ 'zorder': 'The layer level in which to draw'}
169
+
170
+ def _plot3d_options(self, options=None):
171
+ """
172
+ Translate 2d plot options into 3d plot options.
173
+
174
+ EXAMPLES::
175
+
176
+ sage: P = polygon([(1,1), (1,2), (2,2), (2,1)], alpha=.5)
177
+ sage: p=P[0]; p
178
+ Polygon defined by 4 points
179
+ sage: q=p.plot3d()
180
+ sage: q.texture.opacity
181
+ 0.5
182
+ """
183
+ if options is None:
184
+ options = dict(self.options())
185
+ for o in ['thickness', 'zorder', 'legend_label', 'fill', 'edgecolor']:
186
+ options.pop(o, None)
187
+ return GraphicPrimitive_xydata._plot3d_options(self, options)
188
+
189
+ def plot3d(self, z=0, **kwds):
190
+ """
191
+ Plots a 2D polygon in 3D, with default height zero.
192
+
193
+ INPUT:
194
+
195
+ - ``z`` -- (optional) 3D height above `xy`-plane, or a list of
196
+ heights corresponding to the list of 2D polygon points
197
+
198
+ EXAMPLES:
199
+
200
+ A pentagon::
201
+
202
+ sage: polygon([(cos(t), sin(t)) # needs sage.symbolic
203
+ ....: for t in srange(0, 2*pi, 2*pi/5)]).plot3d()
204
+ Graphics3d Object
205
+
206
+ .. PLOT::
207
+
208
+ L = polygon([(cos(t), sin(t)) for t in srange(0, 2*pi, 2*pi/5)]).plot3d()
209
+ sphinx_plot(L)
210
+
211
+ Showing behavior of the optional parameter z::
212
+
213
+ sage: P = polygon([(0,0), (1,2), (0,1), (-1,2)])
214
+ sage: p = P[0]; p
215
+ Polygon defined by 4 points
216
+ sage: q = p.plot3d()
217
+ sage: q.obj_repr(q.testing_render_params())[2]
218
+ ['v 0 0 0', 'v 1 2 0', 'v 0 1 0', 'v -1 2 0']
219
+ sage: r = p.plot3d(z=3)
220
+ sage: r.obj_repr(r.testing_render_params())[2]
221
+ ['v 0 0 3', 'v 1 2 3', 'v 0 1 3', 'v -1 2 3']
222
+ sage: s = p.plot3d(z=[0,1,2,3])
223
+ sage: s.obj_repr(s.testing_render_params())[2]
224
+ ['v 0 0 0', 'v 1 2 1', 'v 0 1 2', 'v -1 2 3']
225
+
226
+ TESTS:
227
+
228
+ Heights passed as a list should have same length as
229
+ number of points::
230
+
231
+ sage: P = polygon([(0,0), (1,2), (0,1), (-1,2)])
232
+ sage: p = P[0]
233
+ sage: q = p.plot3d(z=[2,-2])
234
+ Traceback (most recent call last):
235
+ ...
236
+ ValueError: Incorrect number of heights given
237
+ """
238
+ from sage.plot.plot3d.index_face_set import IndexFaceSet
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
+ return IndexFaceSet([list(zip(self.xdata, self.ydata, zdata))],
248
+ **options)
249
+ else:
250
+ raise ValueError('Incorrect number of heights given')
251
+
252
+ def _render_on_subplot(self, subplot):
253
+ """
254
+ TESTS::
255
+
256
+ sage: P = polygon([(0,0), (1,2), (0,1), (-1,2)])
257
+ """
258
+ import matplotlib.patches as patches
259
+ options = self.options()
260
+ p = patches.Polygon([(self.xdata[i], self.ydata[i])
261
+ for i in range(len(self.xdata))])
262
+ p.set_linewidth(float(options['thickness']))
263
+ if 'linestyle' in options:
264
+ p.set_linestyle(options['linestyle'])
265
+ a = float(options['alpha'])
266
+ z = int(options.pop('zorder', 1))
267
+ p.set_alpha(a)
268
+ f = options.pop('fill')
269
+ p.set_fill(f)
270
+ c = to_mpl_color(options['rgbcolor'])
271
+ if f:
272
+ ec = options['edgecolor']
273
+ if ec is None:
274
+ p.set_color(c)
275
+ else:
276
+ p.set_facecolor(c)
277
+ p.set_edgecolor(to_mpl_color(ec))
278
+ else:
279
+ p.set_color(c)
280
+ p.set_label(options['legend_label'])
281
+ p.set_zorder(z)
282
+ subplot.add_patch(p)
283
+
284
+
285
+ def polygon(points, **options):
286
+ """
287
+ Return either a 2-dimensional or 3-dimensional polygon depending
288
+ on value of points.
289
+
290
+ For information regarding additional arguments, see either
291
+ :func:`polygon2d` or :func:`~sage.plot.plot3d.shapes2.polygon3d`.
292
+ Options may be found and set using the dictionaries ``polygon2d.options``
293
+ and ``polygon3d.options``.
294
+
295
+ EXAMPLES::
296
+
297
+ sage: polygon([(0,0), (1,1), (0,1)])
298
+ Graphics object consisting of 1 graphics primitive
299
+
300
+ .. PLOT::
301
+
302
+ sphinx_plot(polygon([(0,0), (1,1), (0,1)]))
303
+
304
+ ::
305
+
306
+ sage: polygon([(0,0,1), (1,1,1), (2,0,1)])
307
+ Graphics3d Object
308
+
309
+ Extra options will get passed on to show(), as long as they are valid::
310
+
311
+ sage: polygon([(0,0), (1,1), (0,1)], axes=False)
312
+ Graphics object consisting of 1 graphics primitive
313
+ sage: polygon([(0,0), (1,1), (0,1)]).show(axes=False) # These are equivalent
314
+ """
315
+ try:
316
+ return polygon2d(points, **options)
317
+ except ValueError:
318
+ from sage.plot.plot3d.shapes2 import polygon3d
319
+ return polygon3d(points, **options)
320
+
321
+
322
+ @rename_keyword(color='rgbcolor')
323
+ @options(alpha=1, rgbcolor=(0, 0, 1), edgecolor=None, thickness=None,
324
+ legend_label=None, legend_color=None,
325
+ aspect_ratio=1.0, fill=True)
326
+ def polygon2d(points, **options):
327
+ r"""
328
+ Return a 2-dimensional polygon defined by ``points``.
329
+
330
+ Type ``polygon2d.options`` for a dictionary of the default
331
+ options for polygons. You can change this to change the
332
+ defaults for all future polygons. Use ``polygon2d.reset()``
333
+ to reset to the default options.
334
+
335
+ EXAMPLES:
336
+
337
+ We create a purple-ish polygon::
338
+
339
+ sage: polygon2d([[1,2], [5,6], [5,0]], rgbcolor=(1,0,1))
340
+ Graphics object consisting of 1 graphics primitive
341
+
342
+ .. PLOT::
343
+
344
+ sphinx_plot(polygon2d([[1,2], [5,6], [5,0]], rgbcolor=(1,0,1)))
345
+
346
+ By default, polygons are filled in, but we can make them
347
+ without a fill as well::
348
+
349
+ sage: polygon2d([[1,2], [5,6], [5,0]], fill=False)
350
+ Graphics object consisting of 1 graphics primitive
351
+
352
+ .. PLOT::
353
+
354
+ sphinx_plot(polygon2d([[1,2], [5,6], [5,0]], fill=False))
355
+
356
+ In either case, the thickness of the border can be controlled::
357
+
358
+ sage: polygon2d([[1,2], [5,6], [5,0]], fill=False, thickness=4, color='orange')
359
+ Graphics object consisting of 1 graphics primitive
360
+
361
+ .. PLOT::
362
+
363
+ P = polygon2d([[1,2], [5,6], [5,0]], fill=False, thickness=4, color='orange')
364
+ sphinx_plot(P)
365
+
366
+ For filled polygons, one can use different colors for the border
367
+ and the interior as follows::
368
+
369
+ sage: L = [[0,0]]+[[i/100, 1.1+cos(i/20)] for i in range(100)]+[[1,0]] # needs sage.symbolic
370
+ sage: polygon2d(L, color='limegreen', edgecolor='black', axes=False) # needs sage.symbolic
371
+ Graphics object consisting of 1 graphics primitive
372
+
373
+ .. PLOT::
374
+
375
+ L = [[0,0]]+[[i*0.01, 1.1+cos(i*0.05)] for i in range(100)]+[[1,0]]
376
+ P = polygon2d(L, color='limegreen', edgecolor='black', axes=False)
377
+ sphinx_plot(P)
378
+
379
+ Some modern art -- a random polygon, with legend::
380
+
381
+ sage: v = [(randrange(-5,5), randrange(-5,5)) for _ in range(10)]
382
+ sage: polygon2d(v, legend_label='some form')
383
+ Graphics object consisting of 1 graphics primitive
384
+
385
+ .. PLOT::
386
+
387
+ v = [(randrange(-5,5), randrange(-5,5)) for _ in range(10)]
388
+ P = polygon2d(v, legend_label='some form')
389
+ sphinx_plot(P)
390
+
391
+ An aperiodic monotile, [Smi2023]_::
392
+
393
+ sage: s = sqrt(3) # needs sage.symbolic
394
+ sage: polygon2d([[0, 0], [0, s], [1, s], [3/2, 3/2*s], [3, s], [3, 0], [4, 0], # needs sage.symbolic
395
+ ....: [9/2, -1/2*s], [3, -s], [3/2, -1/2*s], [1, -s], [-1, -s],
396
+ ....: [-3/2, -1/2*s]], axes=False)
397
+ Graphics object consisting of 1 graphics primitive
398
+
399
+ .. PLOT::
400
+
401
+ s = sqrt(3)
402
+ P = polygon2d([[0, 0], [0, s], [1, s], [3/2, 3/2*s], [3, s], [3, 0], [4, 0], [9/2, -1/2*s], [3, -s], \
403
+ [3/2, -1/2*s], [1, -s], [-1, -s], [-3/2, -1/2*s]], axes=False)
404
+ sphinx_plot(P)
405
+
406
+ A purple hexagon::
407
+
408
+ sage: L = [[cos(pi*i/3),sin(pi*i/3)] for i in range(6)] # needs sage.symbolic
409
+ sage: polygon2d(L, rgbcolor=(1,0,1)) # needs sage.symbolic
410
+ Graphics object consisting of 1 graphics primitive
411
+
412
+ .. PLOT::
413
+
414
+ L = [[cos(pi*i/3.0),sin(pi*i/3.0)] for i in range(6)]
415
+ P = polygon2d(L, rgbcolor=(1,0,1))
416
+ sphinx_plot(P)
417
+
418
+ A green deltoid::
419
+
420
+ sage: L = [[-1+cos(pi*i/100)*(1+cos(pi*i/100)), # needs sage.symbolic
421
+ ....: 2*sin(pi*i/100)*(1-cos(pi*i/100))] for i in range(200)]
422
+ sage: polygon2d(L, rgbcolor=(1/8,3/4,1/2)) # needs sage.symbolic
423
+ Graphics object consisting of 1 graphics primitive
424
+
425
+ .. PLOT::
426
+
427
+ L = [[-1+cos(pi*i*0.01)*(1+cos(pi*i*0.01)),2*sin(pi*i*0.01)*(1-cos(pi*i*0.01))] for i in range(200)]
428
+ P = polygon2d(L, rgbcolor=(0.125,0.75,0.5))
429
+ sphinx_plot(P)
430
+
431
+ A blue hypotrochoid::
432
+
433
+ sage: L = [[6*cos(pi*i/100)+5*cos((6/2)*pi*i/100), # needs sage.symbolic
434
+ ....: 6*sin(pi*i/100)-5*sin((6/2)*pi*i/100)] for i in range(200)]
435
+ sage: polygon2d(L, rgbcolor=(1/8,1/4,1/2)) # needs sage.symbolic
436
+ Graphics object consisting of 1 graphics primitive
437
+
438
+ .. PLOT::
439
+
440
+ L = [[6*cos(pi*i*0.01)+5*cos(3*pi*i*0.01),6*sin(pi*i*0.01)-5*sin(3*pi*i*0.01)] for i in range(200)]
441
+ P = polygon2d(L, rgbcolor=(0.125,0.25,0.5))
442
+ sphinx_plot(P)
443
+
444
+ Another one::
445
+
446
+ sage: n = 4; h = 5; b = 2
447
+ sage: L = [[n*cos(pi*i/100)+h*cos((n/b)*pi*i/100), # needs sage.symbolic
448
+ ....: n*sin(pi*i/100)-h*sin((n/b)*pi*i/100)] for i in range(200)]
449
+ sage: polygon2d(L, rgbcolor=(1/8,1/4,3/4)) # needs sage.symbolic
450
+ Graphics object consisting of 1 graphics primitive
451
+
452
+ .. PLOT::
453
+
454
+ n = 4.0; h = 5.0; b = 2.0
455
+ L = [[n*cos(pi*i*0.01)+h*cos((n/b)*pi*i*0.01),n*sin(pi*i*0.01)-h*sin((n/b)*pi*i*0.01)] for i in range(200)]
456
+ P = polygon2d(L, rgbcolor=(0.125,0.25,0.75))
457
+ sphinx_plot(P)
458
+
459
+ A purple epicycloid::
460
+
461
+ sage: m = 9; b = 1
462
+ sage: L = [[m*cos(pi*i/100)+b*cos((m/b)*pi*i/100), # needs sage.symbolic
463
+ ....: m*sin(pi*i/100)-b*sin((m/b)*pi*i/100)] for i in range(200)]
464
+ sage: polygon2d(L, rgbcolor=(7/8,1/4,3/4)) # needs sage.symbolic
465
+ Graphics object consisting of 1 graphics primitive
466
+
467
+ .. PLOT::
468
+
469
+ m = 9.0; b = 1
470
+ L = [[m*cos(pi*i*0.01)+b*cos((m/b)*pi*i*0.01),m*sin(pi*i*0.01)-b*sin((m/b)*pi*i*0.01)] for i in range(200)]
471
+ P = polygon2d(L, rgbcolor=(0.875,0.25,0.75))
472
+ sphinx_plot(P)
473
+
474
+ A brown astroid::
475
+
476
+ sage: L = [[cos(pi*i/100)^3, sin(pi*i/100)^3] for i in range(200)] # needs sage.symbolic
477
+ sage: polygon2d(L, rgbcolor=(3/4,1/4,1/4)) # needs sage.symbolic
478
+ Graphics object consisting of 1 graphics primitive
479
+
480
+ .. PLOT::
481
+
482
+ L = [[cos(pi*i*0.01)**3,sin(pi*i*0.01)**3] for i in range(200)]
483
+ P = polygon2d(L, rgbcolor=(0.75,0.25,0.25))
484
+ sphinx_plot(P)
485
+
486
+ And, my favorite, a greenish blob::
487
+
488
+ sage: L = [[cos(pi*i/100)*(1+cos(pi*i/50)), # needs sage.symbolic
489
+ ....: sin(pi*i/100)*(1+sin(pi*i/50))] for i in range(200)]
490
+ sage: polygon2d(L, rgbcolor=(1/8,3/4,1/2)) # needs sage.symbolic
491
+ Graphics object consisting of 1 graphics primitive
492
+
493
+ .. PLOT::
494
+
495
+ L = [[cos(pi*i*0.01)*(1+cos(pi*i*0.02)), sin(pi*i*0.01)*(1+sin(pi*i*0.02))] for i in range(200)]
496
+ P = polygon2d(L, rgbcolor=(0.125,0.75,0.5))
497
+ sphinx_plot(P)
498
+
499
+ This one is for my wife::
500
+
501
+ sage: L = [[sin(pi*i/100)+sin(pi*i/50), # needs sage.symbolic
502
+ ....: -(1+cos(pi*i/100)+cos(pi*i/50))] for i in range(-100,100)]
503
+ sage: polygon2d(L, rgbcolor=(1,1/4,1/2)) # needs sage.symbolic
504
+ Graphics object consisting of 1 graphics primitive
505
+
506
+ .. PLOT::
507
+
508
+ L = [[sin(pi*i*0.01)+sin(pi*i*0.02),-(1+cos(pi*i*0.01)+cos(pi*i*0.02))] for i in range(-100,100)]
509
+ P = polygon2d(L, rgbcolor=(1,0.25,0.5))
510
+ sphinx_plot(P)
511
+
512
+ One can do the same one with a colored legend label::
513
+
514
+ sage: polygon2d(L, color='red', legend_label='For you!', legend_color='red') # needs sage.symbolic
515
+ Graphics object consisting of 1 graphics primitive
516
+
517
+ .. PLOT::
518
+
519
+ L = [[sin(pi*i*0.01)+sin(pi*i*0.02),-(1+cos(pi*i*0.01)+cos(pi*i*0.02))] for i in range(-100,100)]
520
+ P = polygon2d(L, color='red', legend_label='For you!', legend_color='red')
521
+ sphinx_plot(P)
522
+
523
+ Polygons have a default aspect ratio of 1.0::
524
+
525
+ sage: polygon2d([[1,2], [5,6], [5,0]]).aspect_ratio()
526
+ 1.0
527
+
528
+ TESTS:
529
+
530
+ Verify that :issue:`36153` does not arise::
531
+
532
+ sage: P = polygon2d([[1,2], [5,6], [5,0]], legend_label='test')
533
+
534
+ AUTHORS:
535
+
536
+ - David Joyner (2006-04-14): the long list of examples above.
537
+ """
538
+ from sage.plot.plot import xydata_from_point_list
539
+ from sage.plot.all import Graphics
540
+ if options["thickness"] is None: # If the user did not specify thickness
541
+ if options["fill"] and options["edgecolor"] is None:
542
+ # If the user chose fill
543
+ options["thickness"] = 0
544
+ else:
545
+ options["thickness"] = 1
546
+ xdata, ydata = xydata_from_point_list(points)
547
+ g = Graphics()
548
+
549
+ # Reset aspect_ratio to 'automatic' in case scale is 'semilog[xy]'.
550
+ # Otherwise matplotlib complains.
551
+ scale = options.get('scale', None)
552
+ if isinstance(scale, (list, tuple)):
553
+ scale = scale[0]
554
+ if scale == 'semilogy' or scale == 'semilogx':
555
+ options['aspect_ratio'] = 'automatic'
556
+
557
+ g._set_extra_kwds(Graphics._extract_kwds_for_show(options))
558
+ g.add_primitive(Polygon(xdata, ydata, options))
559
+ if options['legend_label']:
560
+ g.legend(True)
561
+ g._legend_colors = [options['legend_color']]
562
+ return g