This module provides a helper class ToricPlotter for producing plots of objects related to toric geometry. Default plotting objects can be adjusted using options() and reset using reset_options().
AUTHORS:
EXAMPLES:
In most cases, this module is used indirectly, e.g.
sage: fan = toric_varieties.dP6().fan()
sage: print fan.plot()
Graphics object consisting of 31 graphics primitives
You may change default plotting options as follows:
sage: toric_plotter.options("show_rays")
True
sage: toric_plotter.options(show_rays=False)
sage: toric_plotter.options("show_rays")
False
sage: print fan.plot()
Graphics object consisting of 19 graphics primitives
sage: toric_plotter.reset_options()
sage: toric_plotter.options("show_rays")
True
sage: print fan.plot()
Graphics object consisting of 31 graphics primitives
Bases: sage.structure.sage_object.SageObject
Create a toric plotter.
INPUT:
OUTPUT:
EXAMPLES:
In most cases there is no need to create and use ToricPlotter directly. Instead, use plotting method of the object which you want to plot, e.g.
sage: fan = toric_varieties.dP6().fan()
sage: fan.plot()
sage: print fan.plot()
Graphics object consisting of 31 graphics primitives
If you do want to create your own plotting function for some toric structure, the anticipated usage of toric plotters is the following:
For example, the plot from the previous example can be obtained as follows:
sage: from sage.geometry.toric_plotter import ToricPlotter
sage: options = dict() # use default for everything
sage: tp = ToricPlotter(options, fan.lattice().degree())
sage: tp.include_points(fan.rays())
sage: tp.adjust_options()
sage: tp.set_rays(fan.rays())
sage: result = tp.plot_lattice()
sage: result += tp.plot_rays()
sage: result += tp.plot_generators()
sage: result += tp.plot_walls(fan(2))
sage: print result
Graphics object consisting of 31 graphics primitives
In most situations it is only necessary to include generators of rays, in this case they can be passed to the constructor as an optional argument. In the example above, the toric plotter can be completely set up using
sage: tp = ToricPlotter(options, fan.lattice().degree(), fan.rays())
All options are exposed as attributes of toric plotters and can be modified after constructions, however you will have to manually call adjust_options() and set_rays() again if you decide to change the plotting mode and/or cut-off bounds. Otherwise plots maybe invalid.
Adjust plotting options.
This function determines appropriate default values for those options, that were not specified by the user, based on the other options. See ToricPlotter for a detailed example.
OUTPUT:
TESTS:
sage: from sage.geometry.toric_plotter import ToricPlotter
sage: tp = ToricPlotter(dict(), 2)
sage: print tp.show_lattice
None
sage: tp.adjust_options()
sage: print tp.show_lattice
True
Try to include points into the bounding box of self.
INPUT:
OUTPUT:
EXAMPLES:
sage: from sage.geometry.toric_plotter import ToricPlotter
sage: tp = ToricPlotter(dict(), 2)
sage: print tp.radius
None
sage: tp.include_points([(3, 4)])
sage: print tp.radius
5.5...
sage: tp.include_points([(5, 12)])
sage: print tp.radius
5.5...
sage: tp.include_points([(5, 12)], force=True)
sage: print tp.radius
13.5...
Plot ray generators.
Ray generators must be specified during construction or using set_rays() before calling this method.
OUTPUT:
EXAMPLES:
sage: from sage.geometry.toric_plotter import ToricPlotter
sage: tp = ToricPlotter(dict(), 2, [(3,4)])
sage: print tp.plot_generators()
Graphics object consisting of 1 graphics primitive
Plot labels at specified positions.
INPUT:
OUTPUT:
EXAMPLES:
sage: from sage.geometry.toric_plotter import ToricPlotter
sage: tp = ToricPlotter(dict(), 2)
sage: print tp.plot_labels("u", [(1.5,0)])
Graphics object consisting of 1 graphics primitive
Plot the lattice (i.e. its points in the cut-off bounds of self).
OUTPUT:
EXAMPLES:
sage: from sage.geometry.toric_plotter import ToricPlotter
sage: tp = ToricPlotter(dict(), 2)
sage: print tp.plot_lattice()
Graphics object consisting of 1 graphics primitive
Plot given points.
INPUT:
OUTPUT:
EXAMPLES:
sage: from sage.geometry.toric_plotter import ToricPlotter
sage: tp = ToricPlotter(dict(), 2)
sage: print tp.plot_points([(1,0), (0,1)])
Graphics object consisting of 1 graphics primitive
Plot ray labels.
Usually ray labels are plotted together with rays, but in some cases it is desirable to output them separately.
Ray generators must be specified during construction or using set_rays() before calling this method.
OUTPUT:
EXAMPLES:
sage: from sage.geometry.toric_plotter import ToricPlotter
sage: tp = ToricPlotter(dict(), 2, [(3,4)])
sage: print tp.plot_ray_labels()
Graphics object consisting of 1 graphics primitive
Plot rays and their labels.
Ray generators must be specified during construction or using set_rays() before calling this method.
OUTPUT:
EXAMPLES:
sage: from sage.geometry.toric_plotter import ToricPlotter
sage: tp = ToricPlotter(dict(), 2, [(3,4)])
sage: print tp.plot_rays()
Graphics object consisting of 2 graphics primitives
Plot walls, i.e. 2-d cones, and their labels.
Ray generators must be specified during construction or using set_rays() before calling this method and these specified ray generators will be used in conjunction with ambient_ray_indices() of walls.
INPUT:
OUTPUT:
EXAMPLES:
sage: quadrant = Cone([(1,0), (0,1)])
sage: from sage.geometry.toric_plotter import ToricPlotter
sage: tp = ToricPlotter(dict(), 2, quadrant.rays())
sage: print tp.plot_walls([quadrant])
Graphics object consisting of 2 graphics primitives
Let’s also check that the truncating polyhedron is functioning correctly:
sage: tp = ToricPlotter({"mode": "box"}, 2, quadrant.rays())
sage: print tp.plot_walls([quadrant])
Graphics object consisting of 2 graphics primitives
Set up rays and their generators to be used by plotting functions.
As an alternative to using this method, you can pass generators to ToricPlotter constructor.
INPUT:
OUTPUT:
EXAMPLES:
sage: from sage.geometry.toric_plotter import ToricPlotter
sage: tp = ToricPlotter(dict(), 2)
sage: tp.adjust_options()
sage: print tp.plot_rays()
Traceback (most recent call last):
...
AttributeError: 'ToricPlotter' object has no attribute 'rays'
sage: tp.set_rays([(0,1)])
sage: print tp.plot_rays()
Graphics object consisting of 2 graphics primitives
Normalize a list of n colors.
INPUT:
OUTPUT:
If color specified a single color, it is repeated n times. If it was a list of n colors, it is returned without changes. If it was “rainbow”, the rainbow of n colors is returned.
EXAMPLES:
sage: from sage.geometry.toric_plotter import color_list
sage: color_list("grey", 1)
[RGB color (0.5019607843137255, 0.5019607843137255, 0.5019607843137255)]
sage: len(color_list("grey", 3))
3
sage: L = color_list("rainbow", 3)
sage: L
[RGB color (1.0, 0.0, 0.0),
RGB color (0.0, 1.0, 0.0),
RGB color (0.0, 0.0, 1.0)]
sage: color_list(L, 3)
[RGB color (1.0, 0.0, 0.0),
RGB color (0.0, 1.0, 0.0),
RGB color (0.0, 0.0, 1.0)]
sage: color_list(L, 4)
Traceback (most recent call last):
...
ValueError: expected 4 colors, got 3!
Normalize a list of n labels.
INPUT:
OUTPUT:
If label was a list of n entries, it is returned without changes.
If label is None, a list of n None‘s is returned. If
label is a string, a list of strings of the form “” is
returned, where
ranges over index_set. (If math_mode=False, the
form “label_i” is used instead.) If n=1, there is no subscript added,
unless index_set was specified explicitly.
EXAMPLES:
sage: from sage.geometry.toric_plotter import label_list
sage: label_list("u", 3, False)
['u_0', 'u_1', 'u_2']
sage: label_list("u", 3, True)
['$u_{0}$', '$u_{1}$', '$u_{2}$']
sage: label_list("u", 1, True)
['$u$']
Get or set options for plots of toric geometry objects.
Note
This function provides access to global default options. Any of these options can be overridden by passing them directly to plotting functions. See also reset_options().
INPUT:
OR:
OR:
OUTPUT:
Name Conventions
To clearly distinguish parts of toric plots, in options and methods we use the following name conventions:
Plotting Modes
A plotting mode mostly determines the shape of the cut-off region (which is always relevant for toric plots except for trivial objects consisting of the origin only). The following options are available:
Available Options
Default values for the following options can be set using this function:
You can see the current default value of any options by typing, e.g.
sage: toric_plotter.options("show_rays")
True
If the default value is None, it means that the actual default is determined later based on the known options. Note, that not all options can be determined in such a way, so you should not set options to None unless it was its original state. (You can always revert to this “original state” using reset_options().)
EXAMPLES:
The following line will make all subsequent toric plotting commands to draw “rainbows” from walls:
sage: toric_plotter.options(wall_color="rainbow")
If you prefer a less colorful output (e.g. if you need black-and-white illustrations for a paper), you can use something like this:
sage: toric_plotter.options(wall_color="grey")
Reset options for plots of toric geometry objects.
OUTPUT:
EXAMPLES:
sage: toric_plotter.options("show_rays")
True
sage: toric_plotter.options(show_rays=False)
sage: toric_plotter.options("show_rays")
False
Now all toric plots will not show rays, unless explicitly requested. If you want to go back to “default defaults”, use this method:
sage: toric_plotter.reset_options()
sage: toric_plotter.options("show_rays")
True
Plot a sector between ray1 and ray2 centered at the origin.
Note
This function was intended for plotting strictly convex cones, so it plots the smaller sector between ray1 and ray2 and, therefore, they cannot be opposite. If you do want to use this function for bigger regions, split them into several parts.
Note
As of version 4.6 Sage does not have a graphic primitive for sectors in 3-dimensional space, so this function will actually approximate them using polygons (the number of vertices used depends on the angle between rays).
INPUT:
OUTPUT:
EXAMPLES:
sage: from sage.geometry.toric_plotter import sector
sage: print sector((1,0), (0,1))
Graphics object consisting of 1 graphics primitive
sage: print sector((3,2,1), (1,2,3))
Graphics3d Object