# Points#

class sage.plot.point.Point(xdata, ydata, options)[source]#

Primitive class for the point graphics type. See point?, point2d? or point3d? for information about actually plotting points.

INPUT:

• xdata – list of x values for points in Point object

• ydata – list of y values for points in Point object

• options – dict of valid plot options to pass to constructor

EXAMPLES:

Note this should normally be used indirectly via point() and friends:

sage: from sage.plot.point import Point
sage: P = Point([1,2],[2,3],{'alpha':.5})
sage: P
Point set defined by 2 point(s)
sage: P.options()['alpha']
0.500000000000000
sage: P.xdata
[1, 2]

>>> from sage.all import *
>>> from sage.plot.point import Point
>>> P = Point([Integer(1),Integer(2)],[Integer(2),Integer(3)],{'alpha':RealNumber('.5')})
>>> P
Point set defined by 2 point(s)
>>> P.options()['alpha']
0.500000000000000
>>> P.xdata
[1, 2]

plot3d(z=0, **kwds)[source]#

Plots a two-dimensional point in 3-D, with default height zero.

INPUT:

• z – optional 3D height above $$xy$$-plane. May be a list if self is a list of points.

EXAMPLES:

One point:

sage: A = point((1, 1))
sage: a = A[0]; a
Point set defined by 1 point(s)
sage: b = a.plot3d()

>>> from sage.all import *
>>> A = point((Integer(1), Integer(1)))
>>> a = A[Integer(0)]; a
Point set defined by 1 point(s)
>>> b = a.plot3d()


One point with a height:

sage: A = point((1, 1))
sage: a = A[0]; a
Point set defined by 1 point(s)
sage: b = a.plot3d(z=3)
sage: b.loc[2]
3.0

>>> from sage.all import *
>>> A = point((Integer(1), Integer(1)))
>>> a = A[Integer(0)]; a
Point set defined by 1 point(s)
>>> b = a.plot3d(z=Integer(3))
>>> b.loc[Integer(2)]
3.0


Multiple points:

sage: P = point([(0, 0), (1, 1)])
sage: p = P[0]; p
Point set defined by 2 point(s)
sage: q = p.plot3d(size=22)

>>> from sage.all import *
>>> P = point([(Integer(0), Integer(0)), (Integer(1), Integer(1))])
>>> p = P[Integer(0)]; p
Point set defined by 2 point(s)
>>> q = p.plot3d(size=Integer(22))


Multiple points with different heights:

sage: P = point([(0, 0), (1, 1)])
sage: p = P[0]
sage: q = p.plot3d(z=[2,3])
sage: q.all[0].loc[2]
2.0
sage: q.all[1].loc[2]
3.0

>>> from sage.all import *
>>> P = point([(Integer(0), Integer(0)), (Integer(1), Integer(1))])
>>> p = P[Integer(0)]
>>> q = p.plot3d(z=[Integer(2),Integer(3)])
>>> q.all[Integer(0)].loc[Integer(2)]
2.0
>>> q.all[Integer(1)].loc[Integer(2)]
3.0


Note that keywords passed must be valid point3d options:

sage: A = point((1, 1), size=22)
sage: a = A[0]; a
Point set defined by 1 point(s)
sage: b = a.plot3d()
sage: b.size
22
sage: b = a.plot3d(pointsize=23)  # only 2D valid option
sage: b.size
22
sage: b = a.plot3d(size=23) # correct keyword
sage: b.size
23

>>> from sage.all import *
>>> A = point((Integer(1), Integer(1)), size=Integer(22))
>>> a = A[Integer(0)]; a
Point set defined by 1 point(s)
>>> b = a.plot3d()
>>> b.size
22
>>> b = a.plot3d(pointsize=Integer(23))  # only 2D valid option
>>> b.size
22
>>> b = a.plot3d(size=Integer(23)) # correct keyword
>>> b.size
23

sage.plot.point.point(points, **kwds)[source]#

Return either a 2-dimensional or 3-dimensional point or sum of points.

INPUT:

• points – either a single point (as a tuple), a list of points, a single complex number, or a list of complex numbers.

For information regarding additional arguments, see either point2d? or point3d?.

EXAMPLES:

sage: point((1, 2))
Graphics object consisting of 1 graphics primitive

>>> from sage.all import *
>>> point((Integer(1), Integer(2)))
Graphics object consisting of 1 graphics primitive

sage: point((1, 2, 3))
Graphics3d Object

>>> from sage.all import *
>>> point((Integer(1), Integer(2), Integer(3)))
Graphics3d Object

sage: point([(0, 0), (1, 1)])
Graphics object consisting of 1 graphics primitive

>>> from sage.all import *
>>> point([(Integer(0), Integer(0)), (Integer(1), Integer(1))])
Graphics object consisting of 1 graphics primitive

sage: point([(0, 0, 1), (1, 1, 1)])
Graphics3d Object

>>> from sage.all import *
>>> point([(Integer(0), Integer(0), Integer(1)), (Integer(1), Integer(1), Integer(1))])
Graphics3d Object


Extra options will get passed on to show(), as long as they are valid:

sage: point([(cos(theta), sin(theta))                                           # needs sage.symbolic
....:        for theta in srange(0, 2*pi, pi/8)], frame=True)
Graphics object consisting of 1 graphics primitive
sage: point([(cos(theta), sin(theta))               # These are equivalent      # needs sage.symbolic
....:        for theta in srange(0, 2*pi, pi/8)]).show(frame=True)

>>> from sage.all import *
>>> point([(cos(theta), sin(theta))                                           # needs sage.symbolic
...        for theta in srange(Integer(0), Integer(2)*pi, pi/Integer(8))], frame=True)
Graphics object consisting of 1 graphics primitive
>>> point([(cos(theta), sin(theta))               # These are equivalent      # needs sage.symbolic
...        for theta in srange(Integer(0), Integer(2)*pi, pi/Integer(8))]).show(frame=True)

sage.plot.point.point2d(points, alpha=1, aspect_ratio='automatic', faceted=False, legend_color=None, legend_label=None, marker='o', markeredgecolor=None, rgbcolor=(0, 0, 1), size=10, **options)[source]#

A point of size size defined by point = $$(x, y)$$.

INPUT:

• points – either a single point (as a tuple), a list of points, a single complex number, or a list of complex numbers

• alpha – how transparent the point is

• faceted – if True, color the edge of the point (only for 2D plots)

• hue – the color given as a hue

• legend_color – the color of the legend text

• legend_label – the label for this item in the legend

• marker – the marker symbol for 2D plots only (see documentation of plot() for details)

• markeredgecolor – the color of the marker edge (only for 2D plots)

• rgbcolor – the color as an RGB tuple

• size – how big the point is (i.e., area in points^2=(1/72 inch)^2)

• zorder – the layer level in which to draw

EXAMPLES:

A purple point from a single tuple of coordinates:

sage: point((0.5, 0.5), rgbcolor=hue(0.75))
Graphics object consisting of 1 graphics primitive

>>> from sage.all import *
>>> point((RealNumber('0.5'), RealNumber('0.5')), rgbcolor=hue(RealNumber('0.75')))
Graphics object consisting of 1 graphics primitive


Points with customized markers and edge colors:

sage: r = [(random(), random()) for _ in range(10)]
sage: point(r, marker='d', markeredgecolor='red', size=20)
Graphics object consisting of 1 graphics primitive

>>> from sage.all import *
>>> r = [(random(), random()) for _ in range(Integer(10))]
>>> point(r, marker='d', markeredgecolor='red', size=Integer(20))
Graphics object consisting of 1 graphics primitive


Passing an empty list returns an empty plot:

sage: point([])
Graphics object consisting of 0 graphics primitives
sage: import numpy; point(numpy.array([]))
Graphics object consisting of 0 graphics primitives

>>> from sage.all import *
>>> point([])
Graphics object consisting of 0 graphics primitives
>>> import numpy; point(numpy.array([]))
Graphics object consisting of 0 graphics primitives


If you need a 2D point to live in 3-space later, this is possible:

sage: A = point((1, 1))
sage: a = A[0]; a
Point set defined by 1 point(s)
sage: b = a.plot3d(z=3)

>>> from sage.all import *
>>> A = point((Integer(1), Integer(1)))
>>> a = A[Integer(0)]; a
Point set defined by 1 point(s)
>>> b = a.plot3d(z=Integer(3))


This is also true with multiple points:

sage: P = point([(0, 0), (1, 1)])
sage: p = P[0]
sage: q = p.plot3d(z=[2,3])

>>> from sage.all import *
>>> P = point([(Integer(0), Integer(0)), (Integer(1), Integer(1))])
>>> p = P[Integer(0)]
>>> q = p.plot3d(z=[Integer(2),Integer(3)])


Here are some random larger red points, given as a list of tuples:

sage: point(((0.5, 0.5), (1, 2), (0.5, 0.9), (-1, -1)), rgbcolor=hue(1), size=30)
Graphics object consisting of 1 graphics primitive

>>> from sage.all import *
>>> point(((RealNumber('0.5'), RealNumber('0.5')), (Integer(1), Integer(2)), (RealNumber('0.5'), RealNumber('0.9')), (-Integer(1), -Integer(1))), rgbcolor=hue(Integer(1)), size=Integer(30))
Graphics object consisting of 1 graphics primitive


And an example with a legend:

sage: point((0, 0), rgbcolor='black', pointsize=40, legend_label='origin')
Graphics object consisting of 1 graphics primitive

>>> from sage.all import *
>>> point((Integer(0), Integer(0)), rgbcolor='black', pointsize=Integer(40), legend_label='origin')
Graphics object consisting of 1 graphics primitive


The legend can be colored:

sage: P = points([(0, 0), (1, 0)], pointsize=40,
....:            legend_label='origin', legend_color='red')
sage: P + plot(x^2, (x, 0, 1), legend_label='plot', legend_color='green')       # needs sage.symbolic
Graphics object consisting of 2 graphics primitives

>>> from sage.all import *
>>> P = points([(Integer(0), Integer(0)), (Integer(1), Integer(0))], pointsize=Integer(40),
...            legend_label='origin', legend_color='red')
>>> P + plot(x**Integer(2), (x, Integer(0), Integer(1)), legend_label='plot', legend_color='green')       # needs sage.symbolic
Graphics object consisting of 2 graphics primitives


Extra options will get passed on to show(), as long as they are valid:

sage: point([(cos(theta), sin(theta))                                           # needs sage.symbolic
....:        for theta in srange(0, 2*pi, pi/8)], frame=True)
Graphics object consisting of 1 graphics primitive
sage: point([(cos(theta), sin(theta))               # These are equivalent      # needs sage.symbolic
....:        for theta in srange(0, 2*pi, pi/8)]).show(frame=True)

>>> from sage.all import *
>>> point([(cos(theta), sin(theta))                                           # needs sage.symbolic
...        for theta in srange(Integer(0), Integer(2)*pi, pi/Integer(8))], frame=True)
Graphics object consisting of 1 graphics primitive
>>> point([(cos(theta), sin(theta))               # These are equivalent      # needs sage.symbolic
...        for theta in srange(Integer(0), Integer(2)*pi, pi/Integer(8))]).show(frame=True)


For plotting data, we can use a logarithmic scale, as long as we are sure not to include any nonpositive points in the logarithmic direction:

sage: point([(1, 2),(2, 4),(3, 4),(4, 8),(4.5, 32)], scale='semilogy', base=2)
Graphics object consisting of 1 graphics primitive

>>> from sage.all import *
>>> point([(Integer(1), Integer(2)),(Integer(2), Integer(4)),(Integer(3), Integer(4)),(Integer(4), Integer(8)),(RealNumber('4.5'), Integer(32))], scale='semilogy', base=Integer(2))
Graphics object consisting of 1 graphics primitive


Since Sage Version 4.4 (Issue #8599), the size of a 2d point can be given by the argument size instead of pointsize. The argument pointsize is still supported:

sage: point((3, 4), size=100)
Graphics object consisting of 1 graphics primitive

>>> from sage.all import *
>>> point((Integer(3), Integer(4)), size=Integer(100))
Graphics object consisting of 1 graphics primitive

sage: point((3, 4), pointsize=100)
Graphics object consisting of 1 graphics primitive

>>> from sage.all import *
>>> point((Integer(3), Integer(4)), pointsize=Integer(100))
Graphics object consisting of 1 graphics primitive


We can plot a single complex number:

sage: point(1 + I, pointsize=100)                                               # needs sage.symbolic
Graphics object consisting of 1 graphics primitive
sage: point(sqrt(2) + I, pointsize=100)                                         # needs sage.symbolic
Graphics object consisting of 1 graphics primitive

>>> from sage.all import *
>>> point(Integer(1) + I, pointsize=Integer(100))                                               # needs sage.symbolic
Graphics object consisting of 1 graphics primitive
>>> point(sqrt(Integer(2)) + I, pointsize=Integer(100))                                         # needs sage.symbolic
Graphics object consisting of 1 graphics primitive


We can also plot a list of complex numbers:

sage: point([I, 1 + I, 2 + 2*I], pointsize=100)                                 # needs sage.symbolic
Graphics object consisting of 1 graphics primitive

>>> from sage.all import *
>>> point([I, Integer(1) + I, Integer(2) + Integer(2)*I], pointsize=Integer(100))                                 # needs sage.symbolic
Graphics object consisting of 1 graphics primitive

sage.plot.point.points(points, **kwds)[source]#

Return either a 2-dimensional or 3-dimensional point or sum of points.

INPUT:

• points – either a single point (as a tuple), a list of points, a single complex number, or a list of complex numbers.

For information regarding additional arguments, see either point2d? or point3d?.

EXAMPLES:

sage: point((1, 2))
Graphics object consisting of 1 graphics primitive

>>> from sage.all import *
>>> point((Integer(1), Integer(2)))
Graphics object consisting of 1 graphics primitive

sage: point((1, 2, 3))
Graphics3d Object

>>> from sage.all import *
>>> point((Integer(1), Integer(2), Integer(3)))
Graphics3d Object

sage: point([(0, 0), (1, 1)])
Graphics object consisting of 1 graphics primitive

>>> from sage.all import *
>>> point([(Integer(0), Integer(0)), (Integer(1), Integer(1))])
Graphics object consisting of 1 graphics primitive

sage: point([(0, 0, 1), (1, 1, 1)])
Graphics3d Object

>>> from sage.all import *
>>> point([(Integer(0), Integer(0), Integer(1)), (Integer(1), Integer(1), Integer(1))])
Graphics3d Object


Extra options will get passed on to show(), as long as they are valid:

sage: point([(cos(theta), sin(theta))                                           # needs sage.symbolic
....:        for theta in srange(0, 2*pi, pi/8)], frame=True)
Graphics object consisting of 1 graphics primitive
sage: point([(cos(theta), sin(theta))               # These are equivalent      # needs sage.symbolic
....:        for theta in srange(0, 2*pi, pi/8)]).show(frame=True)

>>> from sage.all import *
>>> point([(cos(theta), sin(theta))                                           # needs sage.symbolic
...        for theta in srange(Integer(0), Integer(2)*pi, pi/Integer(8))], frame=True)
Graphics object consisting of 1 graphics primitive
>>> point([(cos(theta), sin(theta))               # These are equivalent      # needs sage.symbolic
...        for theta in srange(Integer(0), Integer(2)*pi, pi/Integer(8))]).show(frame=True)