Plotting primitives

class sage.plot.primitive.GraphicPrimitive(options)[source]

Bases: WithEqualityById, SageObject

Base class for graphics primitives, e.g., things that knows how to draw themselves in 2D.

EXAMPLES:

We create an object that derives from GraphicPrimitive:

sage: P = line([(-1,-2), (3,5)])
sage: P[0]
Line defined by 2 points
sage: type(P[0])
<class 'sage.plot.line.Line'>
>>> from sage.all import *
>>> P = line([(-Integer(1),-Integer(2)), (Integer(3),Integer(5))])
>>> P[Integer(0)]
Line defined by 2 points
>>> type(P[Integer(0)])
<class 'sage.plot.line.Line'>
options()[source]

Return the dictionary of options for this graphics primitive.

By default this function verifies that the options are all valid; if any aren’t, then a verbose message is printed with level 0.

EXAMPLES:

sage: from sage.plot.primitive import GraphicPrimitive
sage: GraphicPrimitive({}).options()
{}
>>> from sage.all import *
>>> from sage.plot.primitive import GraphicPrimitive
>>> GraphicPrimitive({}).options()
{}
plot3d(**kwds)[source]

Plots 3D version of 2D graphics object. Not implemented for base class.

EXAMPLES:

sage: from sage.plot.primitive import GraphicPrimitive
sage: G=GraphicPrimitive({})
sage: G.plot3d()
Traceback (most recent call last):
...
NotImplementedError: 3D plotting not implemented for Graphics primitive
>>> from sage.all import *
>>> from sage.plot.primitive import GraphicPrimitive
>>> G=GraphicPrimitive({})
>>> G.plot3d()
Traceback (most recent call last):
...
NotImplementedError: 3D plotting not implemented for Graphics primitive
set_options(new_options)[source]

Change the options to \(new_options\).

EXAMPLES:

sage: from sage.plot.circle import Circle
sage: c = Circle(0,0,1,{})
sage: c.set_options({'thickness': 0.6})
sage: c.options()
{'thickness': 0.6...}
>>> from sage.all import *
>>> from sage.plot.circle import Circle
>>> c = Circle(Integer(0),Integer(0),Integer(1),{})
>>> c.set_options({'thickness': RealNumber('0.6')})
>>> c.options()
{'thickness': 0.6...}
set_zorder(zorder)[source]

Set the layer in which to draw the object.

EXAMPLES:

sage: P = line([(-2,-3), (3,4)], thickness=4)
sage: p=P[0]
sage: p.set_zorder(2)
sage: p.options()['zorder']
2
sage: Q = line([(-2,-4), (3,5)], thickness=4,zorder=1,hue=.5)
sage: P+Q # blue line on top
Graphics object consisting of 2 graphics primitives
sage: q=Q[0]
sage: q.set_zorder(3)
sage: P+Q # teal line on top
Graphics object consisting of 2 graphics primitives
sage: q.options()['zorder']
3
>>> from sage.all import *
>>> P = line([(-Integer(2),-Integer(3)), (Integer(3),Integer(4))], thickness=Integer(4))
>>> p=P[Integer(0)]
>>> p.set_zorder(Integer(2))
>>> p.options()['zorder']
2
>>> Q = line([(-Integer(2),-Integer(4)), (Integer(3),Integer(5))], thickness=Integer(4),zorder=Integer(1),hue=RealNumber('.5'))
>>> P+Q # blue line on top
Graphics object consisting of 2 graphics primitives
>>> q=Q[Integer(0)]
>>> q.set_zorder(Integer(3))
>>> P+Q # teal line on top
Graphics object consisting of 2 graphics primitives
>>> q.options()['zorder']
3
class sage.plot.primitive.GraphicPrimitive_xydata(options)[source]

Bases: GraphicPrimitive

get_minmax_data()[source]

Return a dictionary with the bounding box data.

EXAMPLES:

sage: d = polygon([[1,2], [5,6], [5,0]], rgbcolor=(1,0,1))[0].get_minmax_data()
sage: d['ymin']
0.0
sage: d['xmin']
1.0
>>> from sage.all import *
>>> d = polygon([[Integer(1),Integer(2)], [Integer(5),Integer(6)], [Integer(5),Integer(0)]], rgbcolor=(Integer(1),Integer(0),Integer(1)))[Integer(0)].get_minmax_data()
>>> d['ymin']
0.0
>>> d['xmin']
1.0

sage: d = point((3, 3), rgbcolor=hue(0.75))[0].get_minmax_data()
sage: d['xmin']
3.0
sage: d['ymin']
3.0
>>> from sage.all import *
>>> d = point((Integer(3), Integer(3)), rgbcolor=hue(RealNumber('0.75')))[Integer(0)].get_minmax_data()
>>> d['xmin']
3.0
>>> d['ymin']
3.0

sage: l = line([(100, 100), (120, 120)])[0]
sage: d = l.get_minmax_data()
sage: d['xmin']
100.0
sage: d['xmax']
120.0
>>> from sage.all import *
>>> l = line([(Integer(100), Integer(100)), (Integer(120), Integer(120))])[Integer(0)]
>>> d = l.get_minmax_data()
>>> d['xmin']
100.0
>>> d['xmax']
120.0