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/primitive.py ADDED
@@ -0,0 +1,249 @@
1
+ # sage_setup: distribution = sagemath-plot
2
+ """
3
+ Plotting primitives
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
+ from sage.misc.fast_methods import WithEqualityById
22
+ from sage.structure.sage_object import SageObject
23
+ from sage.misc.verbose import verbose
24
+
25
+
26
+ class GraphicPrimitive(WithEqualityById, SageObject):
27
+ """
28
+ Base class for graphics primitives, e.g., things that knows how to draw
29
+ themselves in 2D.
30
+
31
+ EXAMPLES:
32
+
33
+ We create an object that derives from GraphicPrimitive::
34
+
35
+ sage: P = line([(-1,-2), (3,5)])
36
+ sage: P[0]
37
+ Line defined by 2 points
38
+ sage: type(P[0])
39
+ <class 'sage.plot.line.Line'>
40
+
41
+ TESTS::
42
+
43
+ sage: hash(circle((0,0),1)) # random
44
+ 42
45
+ """
46
+ def __init__(self, options):
47
+ """
48
+ Create a base class GraphicsPrimitive. All this does is
49
+ set the options.
50
+
51
+ EXAMPLES:
52
+
53
+ We indirectly test this function::
54
+
55
+ sage: from sage.plot.primitive import GraphicPrimitive
56
+ sage: GraphicPrimitive({})
57
+ Graphics primitive
58
+ """
59
+ self._options = options
60
+
61
+ def _allowed_options(self):
62
+ """
63
+ Return the allowed options for a graphics primitive.
64
+
65
+ OUTPUT: a reference to a dictionary
66
+
67
+ EXAMPLES::
68
+
69
+ sage: from sage.plot.primitive import GraphicPrimitive
70
+ sage: GraphicPrimitive({})._allowed_options()
71
+ {}
72
+ """
73
+ return {}
74
+
75
+ def plot3d(self, **kwds):
76
+ """
77
+ Plots 3D version of 2D graphics object. Not implemented
78
+ for base class.
79
+
80
+ EXAMPLES::
81
+
82
+ sage: from sage.plot.primitive import GraphicPrimitive
83
+ sage: G=GraphicPrimitive({})
84
+ sage: G.plot3d()
85
+ Traceback (most recent call last):
86
+ ...
87
+ NotImplementedError: 3D plotting not implemented for Graphics primitive
88
+ """
89
+ raise NotImplementedError("3D plotting not implemented for %s" % self._repr_())
90
+
91
+ def _plot3d_options(self, options=None):
92
+ """
93
+ Translate 2D plot options into 3D plot options.
94
+
95
+ EXAMPLES::
96
+
97
+ sage: P = line([(-1,-2), (3,5)], alpha=.5, thickness=4)
98
+ sage: p = P[0]; p
99
+ Line defined by 2 points
100
+ sage: q=p.plot3d()
101
+ sage: q.thickness
102
+ 4
103
+ sage: q.texture.opacity
104
+ 0.5
105
+ """
106
+ if options is None:
107
+ options = self.options()
108
+ options_3d = {}
109
+ if 'rgbcolor' in options:
110
+ options_3d['rgbcolor'] = options['rgbcolor']
111
+ del options['rgbcolor']
112
+ if 'alpha' in options:
113
+ options_3d['opacity'] = options['alpha']
114
+ del options['alpha']
115
+
116
+ for o in ('legend_color', 'legend_label', 'zorder'):
117
+ if o in options:
118
+ del options[o]
119
+
120
+ if len(options) != 0:
121
+ raise NotImplementedError("Unknown plot3d equivalent for {}".format(
122
+ ", ".join(options.keys())))
123
+ return options_3d
124
+
125
+ def set_zorder(self, zorder):
126
+ """
127
+ Set the layer in which to draw the object.
128
+
129
+ EXAMPLES::
130
+
131
+ sage: P = line([(-2,-3), (3,4)], thickness=4)
132
+ sage: p=P[0]
133
+ sage: p.set_zorder(2)
134
+ sage: p.options()['zorder']
135
+ 2
136
+ sage: Q = line([(-2,-4), (3,5)], thickness=4,zorder=1,hue=.5)
137
+ sage: P+Q # blue line on top
138
+ Graphics object consisting of 2 graphics primitives
139
+ sage: q=Q[0]
140
+ sage: q.set_zorder(3)
141
+ sage: P+Q # teal line on top
142
+ Graphics object consisting of 2 graphics primitives
143
+ sage: q.options()['zorder']
144
+ 3
145
+ """
146
+ self._options['zorder'] = zorder
147
+
148
+ def set_options(self, new_options):
149
+ """
150
+ Change the options to ``new_options``.
151
+
152
+ EXAMPLES::
153
+
154
+ sage: from sage.plot.circle import Circle
155
+ sage: c = Circle(0,0,1,{})
156
+ sage: c.set_options({'thickness': 0.6})
157
+ sage: c.options()
158
+ {'thickness': 0.6...}
159
+ """
160
+ if new_options is not None:
161
+ self._options = new_options
162
+
163
+ def options(self):
164
+ """
165
+ Return the dictionary of options for this graphics primitive.
166
+
167
+ By default this function verifies that the options are all
168
+ valid; if any aren't, then a verbose message is printed with level 0.
169
+
170
+ EXAMPLES::
171
+
172
+ sage: from sage.plot.primitive import GraphicPrimitive
173
+ sage: GraphicPrimitive({}).options()
174
+ {}
175
+ """
176
+ from sage.plot.graphics import do_verify
177
+ from sage.plot.colors import hue
178
+ O = dict(self._options)
179
+ if do_verify:
180
+ A = self._allowed_options()
181
+ t = False
182
+ K = list(A) + ['xmin', 'xmax', 'ymin', 'ymax', 'axes']
183
+ for k, Ok in O.items():
184
+ if k not in K:
185
+ do_verify = False
186
+ verbose(f"WARNING: Ignoring option '{k}'={Ok}",
187
+ level=0)
188
+ t = True
189
+ if t:
190
+ s = "\nThe allowed options for %s are:\n" % self
191
+ K.sort()
192
+ for k in K:
193
+ if k in A:
194
+ s += " %-15s%-60s\n" % (k, A[k])
195
+ verbose(s, level=0)
196
+
197
+ if 'hue' in O:
198
+ t = O['hue']
199
+ if not isinstance(t, (tuple, list)):
200
+ t = [t, 1, 1]
201
+ O['rgbcolor'] = hue(*t)
202
+ del O['hue']
203
+ return O
204
+
205
+ def _repr_(self):
206
+ """
207
+ String representation of this graphics primitive.
208
+
209
+ EXAMPLES::
210
+
211
+ sage: from sage.plot.primitive import GraphicPrimitive
212
+ sage: GraphicPrimitive({})._repr_()
213
+ 'Graphics primitive'
214
+ """
215
+ return "Graphics primitive"
216
+
217
+
218
+ class GraphicPrimitive_xydata(GraphicPrimitive):
219
+ def get_minmax_data(self):
220
+ """
221
+ Return a dictionary with the bounding box data.
222
+
223
+ EXAMPLES::
224
+
225
+ sage: d = polygon([[1,2], [5,6], [5,0]], rgbcolor=(1,0,1))[0].get_minmax_data()
226
+ sage: d['ymin']
227
+ 0.0
228
+ sage: d['xmin']
229
+ 1.0
230
+
231
+ ::
232
+
233
+ sage: d = point((3, 3), rgbcolor=hue(0.75))[0].get_minmax_data()
234
+ sage: d['xmin']
235
+ 3.0
236
+ sage: d['ymin']
237
+ 3.0
238
+
239
+ ::
240
+
241
+ sage: l = line([(100, 100), (120, 120)])[0]
242
+ sage: d = l.get_minmax_data()
243
+ sage: d['xmin']
244
+ 100.0
245
+ sage: d['xmax']
246
+ 120.0
247
+ """
248
+ from sage.plot.plot import minmax_data
249
+ return minmax_data(self.xdata, self.ydata, dict=True)
@@ -0,0 +1,199 @@
1
+ # sage_setup: distribution = sagemath-plot
2
+ """
3
+ Scatter plots
4
+ """
5
+
6
+ # *****************************************************************************
7
+ # Copyright (C) 2006 Alex Clemesha <clemesha@gmail.com>,
8
+ # William Stein <wstein@gmail.com>,
9
+ # 2008 Mike Hansen <mhansen@gmail.com>,
10
+ # 2009 Emily Kirkman
11
+ # 2022 Javier Honrubia <jhonrubia6@alumno.uned.es>
12
+ #
13
+ # Distributed under the terms of the GNU General Public License (GPL)
14
+ #
15
+ # This code is distributed in the hope that it will be useful,
16
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18
+ # General Public License for more details.
19
+ #
20
+ # The full text of the GPL is available at:
21
+ #
22
+ # http://www.gnu.org/licenses/
23
+ # *****************************************************************************
24
+ from sage.plot.primitive import GraphicPrimitive
25
+ from sage.misc.decorators import options
26
+
27
+
28
+ class ScatterPlot(GraphicPrimitive):
29
+ """
30
+ Scatter plot graphics primitive.
31
+
32
+ Input consists of two lists/arrays of the same length, whose
33
+ values give the horizontal and vertical coordinates of each
34
+ point in the scatter plot. Options may be passed in
35
+ dictionary format.
36
+
37
+ EXAMPLES::
38
+
39
+ sage: from sage.plot.scatter_plot import ScatterPlot
40
+ sage: ScatterPlot([0,1,2], [3.5,2,5.1], {'facecolor':'white', 'marker':'s'})
41
+ Scatter plot graphics primitive on 3 data points
42
+ """
43
+ def __init__(self, xdata, ydata, options):
44
+ """
45
+ Scatter plot graphics primitive.
46
+
47
+ EXAMPLES::
48
+
49
+ sage: import numpy
50
+ sage: from sage.plot.scatter_plot import ScatterPlot
51
+ sage: ScatterPlot(numpy.array([0,1,2]), numpy.array([3.5,2,5.1]), {'facecolor':'white', 'marker':'s'})
52
+ Scatter plot graphics primitive on 3 data points
53
+ """
54
+ self.xdata = xdata
55
+ self.ydata = ydata
56
+ GraphicPrimitive.__init__(self, options)
57
+
58
+ def get_minmax_data(self):
59
+ """
60
+ Return a dictionary with the bounding box data.
61
+
62
+ EXAMPLES::
63
+
64
+ sage: s = scatter_plot([[0,1],[2,4],[3.2,6]])
65
+ sage: d = s.get_minmax_data()
66
+ sage: d['xmin']
67
+ ...0.0...
68
+ sage: d['ymin']
69
+ ...1.0...
70
+ """
71
+ return {'xmin': self.xdata.min(),
72
+ 'xmax': self.xdata.max(),
73
+ 'ymin': self.ydata.min(),
74
+ 'ymax': self.ydata.max()}
75
+
76
+ def _allowed_options(self):
77
+ """
78
+ Return the dictionary of allowed options for the scatter plot
79
+ graphics primitive.
80
+
81
+ EXAMPLES::
82
+
83
+ sage: from sage.plot.scatter_plot import ScatterPlot
84
+ sage: list(sorted(ScatterPlot([-1,2], [17,4], {})._allowed_options().items()))
85
+ [('alpha', 'How transparent the marker border is.'),
86
+ ('clip', 'Whether or not to clip.'),
87
+ ('edgecolor', 'The color of the marker border.'),
88
+ ('facecolor', 'The color of the marker face.'),
89
+ ('hue', 'The color given as a hue.'),
90
+ ('marker', 'What shape to plot the points. See the documentation of plot() for the full list of markers.'),
91
+ ('markersize', 'the size of the markers.'),
92
+ ('rgbcolor', 'The color as an RGB tuple.'),
93
+ ('zorder', 'The layer level in which to draw.')]
94
+ """
95
+ return {'markersize': 'the size of the markers.',
96
+ 'marker': 'What shape to plot the points. See the documentation of plot() for the full list of markers.',
97
+ 'alpha': 'How transparent the marker border is.',
98
+ 'rgbcolor': 'The color as an RGB tuple.',
99
+ 'hue': 'The color given as a hue.',
100
+ 'facecolor': 'The color of the marker face.',
101
+ 'edgecolor': 'The color of the marker border.',
102
+ 'zorder': 'The layer level in which to draw.',
103
+ 'clip': 'Whether or not to clip.'}
104
+
105
+ def _repr_(self):
106
+ """
107
+ Text representation of a scatter plot graphics primitive.
108
+
109
+ EXAMPLES::
110
+
111
+ sage: import numpy
112
+ sage: from sage.plot.scatter_plot import ScatterPlot
113
+ sage: ScatterPlot(numpy.array([0,1,2]), numpy.array([3.5,2,5.1]), {})
114
+ Scatter plot graphics primitive on 3 data points
115
+ """
116
+ return 'Scatter plot graphics primitive on %s data points' % len(self.xdata)
117
+
118
+ def _render_on_subplot(self, subplot):
119
+ """
120
+ Render this scatter plot in a subplot. This is the key function that
121
+ defines how this scatter plot graphics primitive is rendered in
122
+ matplotlib's library.
123
+
124
+ EXAMPLES::
125
+
126
+ sage: scatter_plot([[0,1],[2,2],[4.3,1.1]], marker='s')
127
+ Graphics object consisting of 1 graphics primitive
128
+
129
+ ::
130
+
131
+ sage: scatter_plot([[n,n] for n in range(5)])
132
+ Graphics object consisting of 1 graphics primitive
133
+ """
134
+ options = self.options()
135
+ p = subplot.scatter(self.xdata, self.ydata, alpha=options['alpha'],
136
+ zorder=options['zorder'], marker=options['marker'],
137
+ s=options['markersize'], facecolors=options['facecolor'],
138
+ edgecolors=options['edgecolor'], clip_on=options['clip'])
139
+ if not options['clip']:
140
+ self._bbox_extra_artists = [p]
141
+
142
+
143
+ @options(alpha=1, markersize=50, marker='o', zorder=5, facecolor='#fec7b8', edgecolor='black', clip=True, aspect_ratio='automatic')
144
+ def scatter_plot(datalist, **options):
145
+ """
146
+ Return a Graphics object of a scatter plot containing all points in
147
+ the datalist. Type ``scatter_plot.options`` to see all available
148
+ plotting options.
149
+
150
+ INPUT:
151
+
152
+ - ``datalist`` -- list of tuples ``(x,y)``
153
+
154
+ - ``alpha`` -- (default: 1)
155
+
156
+ - ``markersize`` -- (default: 50)
157
+
158
+ - ``marker`` -- the style of the markers (default: ``'o'``); see the
159
+ documentation of :func:`plot` for the full list of markers
160
+
161
+ - ``facecolor`` -- (default: ``'#fec7b8'``)
162
+
163
+ - ``edgecolor`` -- (default: ``'black'``)
164
+
165
+ - ``zorder`` -- (default: 5)
166
+
167
+ EXAMPLES::
168
+
169
+ sage: scatter_plot([[0,1],[2,2],[4.3,1.1]], marker='s')
170
+ Graphics object consisting of 1 graphics primitive
171
+
172
+ .. PLOT::
173
+
174
+ from sage.plot.scatter_plot import ScatterPlot
175
+ S = scatter_plot([[0,1],[2,2],[4.3,1.1]], marker='s')
176
+ sphinx_plot(S)
177
+
178
+ Extra options will get passed on to :meth:`~Graphics.show`, as long as they are valid::
179
+
180
+ sage: scatter_plot([(0, 0), (1, 1)], markersize=100, facecolor='green', ymax=100)
181
+ Graphics object consisting of 1 graphics primitive
182
+ sage: scatter_plot([(0, 0), (1, 1)], markersize=100, facecolor='green').show(ymax=100) # These are equivalent
183
+
184
+ .. PLOT::
185
+
186
+ from sage.plot.scatter_plot import ScatterPlot
187
+ S = scatter_plot([(0, 0), (1, 1)], markersize=100, facecolor='green', ymax=100)
188
+ sphinx_plot(S)
189
+ """
190
+ import numpy
191
+ from sage.plot.all import Graphics
192
+ g = Graphics()
193
+ g._set_extra_kwds(Graphics._extract_kwds_for_show(options))
194
+ data = numpy.array(datalist, dtype='float')
195
+ if len(data) != 0:
196
+ xdata = data[:, 0]
197
+ ydata = data[:, 1]
198
+ g.add_primitive(ScatterPlot(xdata, ydata, options=options))
199
+ return g
sage/plot/step.py ADDED
@@ -0,0 +1,85 @@
1
+ # sage_setup: distribution = sagemath-plot
2
+ # sage.doctest: needs sage.symbolic
3
+ """
4
+ Step function plots
5
+ """
6
+
7
+ # *****************************************************************************
8
+ # Copyright (C) 2009 William Stein <wstein@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
+ from sage.plot.line import line
22
+
23
+
24
+ def plot_step_function(v, vertical_lines=True, **kwds):
25
+ r"""
26
+ Return the line graphics object that gives the plot of the step
27
+ function `f` defined by the list `v` of pairs `(a,b)`. Here if
28
+ `(a,b)` is in `v`, then `f(a) = b`. The user does not have to
29
+ worry about sorting the input list `v`.
30
+
31
+ INPUT:
32
+
33
+ - ``v`` -- list of pairs (a,b)
34
+
35
+ - ``vertical_lines`` -- boolean (default: ``True``); if ``True``, draw
36
+ vertical risers at each step of this step function.
37
+ Technically these vertical lines are not part of the graph
38
+ of this function, but they look very nice in the plot, so we
39
+ include them by default.
40
+
41
+ EXAMPLES:
42
+
43
+ We plot the prime counting function::
44
+
45
+ sage: plot_step_function([(i, prime_pi(i)) for i in range(20)])
46
+ Graphics object consisting of 1 graphics primitive
47
+
48
+ .. PLOT::
49
+
50
+ sphinx_plot(plot_step_function([(i, prime_pi(i)) for i in range(20)]))
51
+
52
+ ::
53
+
54
+ sage: plot_step_function([(i, sin(i)) for i in range(5, 20)])
55
+ Graphics object consisting of 1 graphics primitive
56
+
57
+ .. PLOT::
58
+
59
+ sphinx_plot(plot_step_function([(i, sin(i)) for i in range(5, 20)]))
60
+
61
+ We pass in many options and get something that looks like "Space Invaders"::
62
+
63
+ sage: v = [(i, sin(i)) for i in range(5, 20)]
64
+ sage: plot_step_function(v, vertical_lines=False, thickness=30,
65
+ ....: rgbcolor='purple', axes=False)
66
+ Graphics object consisting of 14 graphics primitives
67
+
68
+ .. PLOT::
69
+
70
+ v = [(i, sin(i)) for i in range(5, 20)]
71
+ sphinx_plot(plot_step_function(v, vertical_lines=False, thickness=30, rgbcolor='purple', axes=False))
72
+ """
73
+ # make sorted copy of v (don't change in place, since that would be rude).
74
+ v = sorted(v)
75
+ if len(v) <= 1:
76
+ return line([]) # empty line
77
+ if vertical_lines:
78
+ w = []
79
+ for i in range(len(v)):
80
+ w.append(v[i])
81
+ if i+1 < len(v):
82
+ w.append((v[i+1][0], v[i][1]))
83
+ return line(w, **kwds)
84
+ else:
85
+ return sum(line([v[i], (v[i+1][0], v[i][1])], **kwds) for i in range(len(v)-1))