class sage.plot.ellipse.Ellipse(x, y, r1, r2, angle, options)

Bases: sage.plot.primitive.GraphicPrimitive

Primitive class for the Ellipse graphics type. See ellipse? for information about actually plotting ellipses.


  • x,y - coordinates of the center of the ellipse
  • r1, r2 - radii of the ellipse
  • angle - angle
  • options - dictionary of options


Note that this construction should be done using ellipse:

sage: from sage.plot.ellipse import Ellipse
sage: Ellipse(0, 0, 2, 1, pi/4, {})
Ellipse centered at (0.0, 0.0) with radii (2.0, 1.0) and angle 0.785398163397

Returns a dictionary with the bounding box data.

The bounding box is computed to be as minimal as possible.


An example without an angle:

sage: p = ellipse((-2, 3), 1, 2)
sage: d = p.get_minmax_data()
sage: d['xmin']
sage: d['xmax']
sage: d['ymin']
sage: d['ymax']

The same example with a rotation of angle \(\pi/2\):

sage: p = ellipse((-2, 3), 1, 2, pi/2)
sage: d = p.get_minmax_data()
sage: d['xmin']
sage: d['xmax']
sage: d['ymin']
sage: d['ymax']

Plotting in 3D is not implemented.


sage: from sage.plot.ellipse import Ellipse
sage: Ellipse(0,0,2,1,pi/4,{}).plot3d()
Traceback (most recent call last):
sage.plot.ellipse.ellipse(center, r1, r2, angle=0, edgecolor='blue', legend_color=None, facecolor='blue', linestyle='solid', thickness=1, zorder=5, aspect_ratio=1.0, alpha=1, legend_label=None, fill=False, **options)

Return an ellipse centered at a point center = (x,y) with radii = r1,r2 and angle angle. Type ellipse.options to see all options.


  • center - 2-tuple of real numbers - coordinates of the center
  • r1, r2 - positive real numbers - the radii of the ellipse
  • angle - real number (default: 0) - the angle between the first axis and the horizontal


  • alpha - default: 1 - transparency
  • fill - default: False - whether to fill the ellipse or not
  • thickness - default: 1 - thickness of the line
  • linestyle - default: 'solid' - The style of the line, which is one of 'dashed', 'dotted', 'solid', 'dashdot', or '--', ':', '-', '-.', respectively.
  • edgecolor - default: ‘black’ - color of the contour
  • facecolor - default: ‘red’ - color of the filling
  • rgbcolor - 2D or 3D plotting. This option overrides edgecolor and facecolor for 2D plotting.
  • legend_label - the label for this item in the legend
  • legend_color - the color for the legend label


An ellipse centered at (0,0) with major and minor axes of lengths 2 and 1. Note that the default color is blue:

sage: ellipse((0,0),2,1)

More complicated examples with tilted axes and drawing options:

sage: ellipse((0,0),3,1,pi/6,fill=True,alpha=0.3,linestyle="dashed")
sage: ellipse((0,0),3,1,pi/6,fill=True,alpha=0.3,linestyle="--")
sage: ellipse((0,0),3,1,pi/6,fill=True,edgecolor='black',facecolor='red')

We see that rgbcolor overrides these other options, as this plot is green:

sage: ellipse((0,0),3,1,pi/6,fill=True,edgecolor='black',facecolor='red',rgbcolor='green')

The default aspect ratio for ellipses is 1.0:

sage: ellipse((0,0),2,1).aspect_ratio()

One cannot yet plot ellipses in 3D:

sage: ellipse((0,0,0),2,1)
Traceback (most recent call last):
NotImplementedError: plotting ellipse in 3D is not implemented

We can also give ellipses a legend:

sage: ellipse((0,0),2,1,legend_label="My ellipse", legend_color='green')

Previous topic


Next topic

Graph Plotting

This Page