Disks

class sage.plot.disk.Disk(point, r, angle, options)[source]

Bases: GraphicPrimitive

Primitive class for the Disk graphics type. See disk? for information about actually plotting a disk (the Sage term for a sector or wedge of a circle).

INPUT:

  • point – coordinates of center of disk

  • r – radius of disk

  • angle – beginning and ending angles of disk (i.e. angle extent of sector/wedge)

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

EXAMPLES:

Note this should normally be used indirectly via disk:

sage: from math import pi
sage: from sage.plot.disk import Disk
sage: D = Disk((1,2), 2, (pi/2,pi), {'zorder':3})
sage: D
Disk defined by (1.0,2.0) with r=2.0
 spanning (1.5707963267..., 3.1415926535...) radians
sage: D.options()['zorder']
3
sage: D.x
1.0
>>> from sage.all import *
>>> from math import pi
>>> from sage.plot.disk import Disk
>>> D = Disk((Integer(1),Integer(2)), Integer(2), (pi/Integer(2),pi), {'zorder':Integer(3)})
>>> D
Disk defined by (1.0,2.0) with r=2.0
 spanning (1.5707963267..., 3.1415926535...) radians
>>> D.options()['zorder']
3
>>> D.x
1.0
from math import pi
from sage.plot.disk import Disk
D = Disk((1,2), 2, (pi/2,pi), {'zorder':3})
D
D.options()['zorder']
D.x
get_minmax_data()[source]

Return a dictionary with the bounding box data.

EXAMPLES:

sage: from math import pi
sage: D = disk((5,4), 1, (pi/2, pi))
sage: d = D.get_minmax_data()
sage: d['xmin']
4.0
sage: d['ymin']
3.0
sage: d['xmax']
6.0
sage: d['ymax']
5.0
>>> from sage.all import *
>>> from math import pi
>>> D = disk((Integer(5),Integer(4)), Integer(1), (pi/Integer(2), pi))
>>> d = D.get_minmax_data()
>>> d['xmin']
4.0
>>> d['ymin']
3.0
>>> d['xmax']
6.0
>>> d['ymax']
5.0
from math import pi
D = disk((5,4), 1, (pi/2, pi))
d = D.get_minmax_data()
d['xmin']
d['ymin']
d['xmax']
d['ymax']
plot3d(z=0, **kwds)[source]

Plots a 2D disk (actually a 52-gon) in 3D, with default height zero.

INPUT:

  • z – (optional) 3D height above \(xy\)-plane

AUTHORS:

  • Karl-Dieter Crisman (05-09)

EXAMPLES:

sage: from math import pi
sage: disk((0,0), 1, (0, pi/2)).plot3d()
Graphics3d Object
sage: disk((0,0), 1, (0, pi/2)).plot3d(z=2)
Graphics3d Object
sage: disk((0,0), 1, (pi/2, 0), fill=False).plot3d(3)
Graphics3d Object
>>> from sage.all import *
>>> from math import pi
>>> disk((Integer(0),Integer(0)), Integer(1), (Integer(0), pi/Integer(2))).plot3d()
Graphics3d Object
>>> disk((Integer(0),Integer(0)), Integer(1), (Integer(0), pi/Integer(2))).plot3d(z=Integer(2))
Graphics3d Object
>>> disk((Integer(0),Integer(0)), Integer(1), (pi/Integer(2), Integer(0)), fill=False).plot3d(Integer(3))
Graphics3d Object
from math import pi
disk((0,0), 1, (0, pi/2)).plot3d()
disk((0,0), 1, (0, pi/2)).plot3d(z=2)
disk((0,0), 1, (pi/2, 0), fill=False).plot3d(3)

These examples show that the appropriate options are passed:

sage: D = disk((2,3), 1, (pi/4,pi/3), hue=.8, alpha=.3, fill=True)
sage: d = D[0]
sage: d.plot3d(z=2).texture.opacity
0.3
>>> from sage.all import *
>>> D = disk((Integer(2),Integer(3)), Integer(1), (pi/Integer(4),pi/Integer(3)), hue=RealNumber('.8'), alpha=RealNumber('.3'), fill=True)
>>> d = D[Integer(0)]
>>> d.plot3d(z=Integer(2)).texture.opacity
0.3
D = disk((2,3), 1, (pi/4,pi/3), hue=.8, alpha=.3, fill=True)
d = D[0]
d.plot3d(z=2).texture.opacity
sage: D = disk((2,3), 1, (pi/4,pi/3), hue=.8, alpha=.3, fill=False)
sage: d = D[0]
sage: dd = d.plot3d(z=2)
sage: dd.jmol_repr(dd.testing_render_params())[0][-1]
'color $line_4 translucent 0.7 [204,0,255]'
>>> from sage.all import *
>>> D = disk((Integer(2),Integer(3)), Integer(1), (pi/Integer(4),pi/Integer(3)), hue=RealNumber('.8'), alpha=RealNumber('.3'), fill=False)
>>> d = D[Integer(0)]
>>> dd = d.plot3d(z=Integer(2))
>>> dd.jmol_repr(dd.testing_render_params())[Integer(0)][-Integer(1)]
'color $line_4 translucent 0.7 [204,0,255]'
D = disk((2,3), 1, (pi/4,pi/3), hue=.8, alpha=.3, fill=False)
d = D[0]
dd = d.plot3d(z=2)
dd.jmol_repr(dd.testing_render_params())[0][-1]
>>> from sage.all import *
>>> D = disk((Integer(2),Integer(3)), Integer(1), (pi/Integer(4),pi/Integer(3)), hue=RealNumber('.8'), alpha=RealNumber('.3'), fill=False)
>>> d = D[Integer(0)]
>>> dd = d.plot3d(z=Integer(2))
>>> dd.jmol_repr(dd.testing_render_params())[Integer(0)][-Integer(1)]
'color $line_4 translucent 0.7 [204,0,255]'
D = disk((2,3), 1, (pi/4,pi/3), hue=.8, alpha=.3, fill=False)
d = D[0]
dd = d.plot3d(z=2)
dd.jmol_repr(dd.testing_render_params())[0][-1]
sage.plot.disk.disk(point, radius, angle, alpha=1, fill=True, rgbcolor=(0, 0, 1), thickness=0, legend_label=None, legend_color=None, aspect_ratio=1.0, **options)[source]

A disk (that is, a sector or wedge of a circle) with center at a point = \((x,y)\) (or \((x,y,z)\) and parallel to the \(xy\)-plane) with radius = \(r\) spanning (in radians) angle=`(rad1, rad2)`.

Type disk.options to see all options.

EXAMPLES:

Make some dangerous disks:

sage: from math import pi
sage: bl = disk((0.0,0.0), 1, (pi, 3*pi/2), color='yellow')
sage: tr = disk((0.0,0.0), 1, (0, pi/2), color='yellow')
sage: tl = disk((0.0,0.0), 1, (pi/2, pi), color='black')
sage: br = disk((0.0,0.0), 1, (3*pi/2, 2*pi), color='black')
sage: P  = tl + tr + bl + br
sage: P.show(xmin=-2, xmax=2, ymin=-2, ymax=2)
>>> from sage.all import *
>>> from math import pi
>>> bl = disk((RealNumber('0.0'),RealNumber('0.0')), Integer(1), (pi, Integer(3)*pi/Integer(2)), color='yellow')
>>> tr = disk((RealNumber('0.0'),RealNumber('0.0')), Integer(1), (Integer(0), pi/Integer(2)), color='yellow')
>>> tl = disk((RealNumber('0.0'),RealNumber('0.0')), Integer(1), (pi/Integer(2), pi), color='black')
>>> br = disk((RealNumber('0.0'),RealNumber('0.0')), Integer(1), (Integer(3)*pi/Integer(2), Integer(2)*pi), color='black')
>>> P  = tl + tr + bl + br
>>> P.show(xmin=-Integer(2), xmax=Integer(2), ymin=-Integer(2), ymax=Integer(2))
from math import pi
bl = disk((0.0,0.0), 1, (pi, 3*pi/2), color='yellow')
tr = disk((0.0,0.0), 1, (0, pi/2), color='yellow')
tl = disk((0.0,0.0), 1, (pi/2, pi), color='black')
br = disk((0.0,0.0), 1, (3*pi/2, 2*pi), color='black')
P  = tl + tr + bl + br
P.show(xmin=-2, xmax=2, ymin=-2, ymax=2)
../../_images/disk-1.svg

The default aspect ratio is 1.0:

sage: disk((0.0,0.0), 1, (pi, 3*pi/2)).aspect_ratio()
1.0
>>> from sage.all import *
>>> disk((RealNumber('0.0'),RealNumber('0.0')), Integer(1), (pi, Integer(3)*pi/Integer(2))).aspect_ratio()
1.0
disk((0.0,0.0), 1, (pi, 3*pi/2)).aspect_ratio()

Another example of a disk:

sage: bl = disk((0.0,0.0), 1, (pi, 3*pi/2), rgbcolor=(1,1,0))
sage: bl.show(figsize=[5,5])
>>> from sage.all import *
>>> bl = disk((RealNumber('0.0'),RealNumber('0.0')), Integer(1), (pi, Integer(3)*pi/Integer(2)), rgbcolor=(Integer(1),Integer(1),Integer(0)))
>>> bl.show(figsize=[Integer(5),Integer(5)])
bl = disk((0.0,0.0), 1, (pi, 3*pi/2), rgbcolor=(1,1,0))
bl.show(figsize=[5,5])
../../_images/disk-2.svg

Note that since thickness defaults to zero, it is best to change that option when using fill=False:

sage: disk((2,3), 1, (pi/4,pi/3), hue=.8, alpha=.3, fill=False, thickness=2)
Graphics object consisting of 1 graphics primitive
>>> from sage.all import *
>>> disk((Integer(2),Integer(3)), Integer(1), (pi/Integer(4),pi/Integer(3)), hue=RealNumber('.8'), alpha=RealNumber('.3'), fill=False, thickness=Integer(2))
Graphics object consisting of 1 graphics primitive
disk((2,3), 1, (pi/4,pi/3), hue=.8, alpha=.3, fill=False, thickness=2)
../../_images/disk-3.svg

The previous two examples also illustrate using hue and rgbcolor as ways of specifying the color of the graphic.

We can also use this command to plot three-dimensional disks parallel to the \(xy\)-plane:

sage: d = disk((1,1,3), 1, (pi,3*pi/2), rgbcolor=(1,0,0))
sage: d
Graphics3d Object
sage: type(d)
<... 'sage.plot.plot3d.index_face_set.IndexFaceSet'>
>>> from sage.all import *
>>> d = disk((Integer(1),Integer(1),Integer(3)), Integer(1), (pi,Integer(3)*pi/Integer(2)), rgbcolor=(Integer(1),Integer(0),Integer(0)))
>>> d
Graphics3d Object
>>> type(d)
<... 'sage.plot.plot3d.index_face_set.IndexFaceSet'>
d = disk((1,1,3), 1, (pi,3*pi/2), rgbcolor=(1,0,0))
d
type(d)
../../_images/disk-4.svg

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

sage: disk((0, 0), 5, (0, pi/2), rgbcolor=(1, 0, 1),
....:      xmin=0, xmax=5, ymin=0, ymax=5, figsize=(2,2))
Graphics object consisting of 1 graphics primitive
sage: disk((0, 0), 5, (0, pi/2), rgbcolor=(1, 0, 1)).show(  # These are equivalent
....:     xmin=0, xmax=5, ymin=0, ymax=5, figsize=(2,2))
>>> from sage.all import *
>>> disk((Integer(0), Integer(0)), Integer(5), (Integer(0), pi/Integer(2)), rgbcolor=(Integer(1), Integer(0), Integer(1)),
...      xmin=Integer(0), xmax=Integer(5), ymin=Integer(0), ymax=Integer(5), figsize=(Integer(2),Integer(2)))
Graphics object consisting of 1 graphics primitive
>>> disk((Integer(0), Integer(0)), Integer(5), (Integer(0), pi/Integer(2)), rgbcolor=(Integer(1), Integer(0), Integer(1))).show(  # These are equivalent
...     xmin=Integer(0), xmax=Integer(5), ymin=Integer(0), ymax=Integer(5), figsize=(Integer(2),Integer(2)))
disk((0, 0), 5, (0, pi/2), rgbcolor=(1, 0, 1),
     xmin=0, xmax=5, ymin=0, ymax=5, figsize=(2,2))
disk((0, 0), 5, (0, pi/2), rgbcolor=(1, 0, 1)).show(  # These are equivalent
    xmin=0, xmax=5, ymin=0, ymax=5, figsize=(2,2))