本文整理汇总了Python中sage.plot.graphics.Graphics.aspect_ratio方法的典型用法代码示例。如果您正苦于以下问题:Python Graphics.aspect_ratio方法的具体用法?Python Graphics.aspect_ratio怎么用?Python Graphics.aspect_ratio使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sage.plot.graphics.Graphics
的用法示例。
在下文中一共展示了Graphics.aspect_ratio方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: finalize
# 需要导入模块: from sage.plot.graphics import Graphics [as 别名]
# 或者: from sage.plot.graphics.Graphics import aspect_ratio [as 别名]
def finalize(self, G):
r"""
Finalize a root system plot.
INPUT:
- ``G`` -- a root system plot or ``0``
This sets the aspect ratio to 1 and remove the axes. This
should be called by all the user-level plotting methods of
root systems. This will become mostly obsolete when
customization options won't be lost anymore upon addition of
graphics objects and there will be a proper empty object for
2D and 3D plots.
EXAMPLES::
sage: L = RootSystem(["B",2,1]).ambient_space()
sage: options = L.plot_parse_options()
sage: p = L.plot_roots(plot_options=options)
sage: p += L.plot_coroots(plot_options=options)
sage: p.axes()
True
sage: p = options.finalize(p)
sage: p.axes()
False
sage: p.aspect_ratio()
1.0
sage: options = L.plot_parse_options(affine=False)
sage: p = L.plot_roots(plot_options=options)
sage: p += point([[1,1,0]])
sage: p = options.finalize(p)
sage: p.aspect_ratio()
[1.0, 1.0, 1.0]
If the input is ``0``, this returns an empty graphics object::
sage: type(options.finalize(0))
<class 'sage.plot.plot3d.base.Graphics3dGroup'>
sage: options = L.plot_parse_options()
sage: type(options.finalize(0))
<class 'sage.plot.graphics.Graphics'>
sage: list(options.finalize(0))
[]
"""
from sage.plot.graphics import Graphics
if self.dimension == 2:
if G == 0:
G = Graphics()
G.set_aspect_ratio(1)
# TODO: make this customizable
G.axes(False)
elif self.dimension == 3:
if G == 0:
from sage.plot.plot3d.base import Graphics3dGroup
G = Graphics3dGroup()
G.aspect_ratio(1)
# TODO: Configuration axes
return G
示例2: plot
# 需要导入模块: from sage.plot.graphics import Graphics [as 别名]
# 或者: from sage.plot.graphics.Graphics import aspect_ratio [as 别名]
def plot(self, chart=None, ambient_coords=None, mapping=None, prange=None,
include_end_point=(True, True), end_point_offset=(0.001, 0.001),
max_value=8, parameters=None, color='red', style='-',
thickness=1, plot_points=75, label_axes=True,
aspect_ratio='automatic'):
r"""
Plot the current curve (``self``) in a Cartesian graph based on the
coordinates of some ambient chart.
The curve is drawn in terms of two (2D graphics) or three (3D graphics)
coordinates of a given chart, called hereafter the *ambient chart*.
The ambient chart's domain must overlap with the curve's codomain or
with the codomain of the composite curve `\Phi\circ c`, where `c` is
``self`` and `\Phi` some manifold differential mapping (argument
``mapping`` below).
INPUT:
- ``chart`` -- (default: ``None``) the ambient chart (see above);
if ``None``, the default chart of the codomain of the curve (or of
the curve composed with `\Phi`) is used
- ``ambient_coords`` -- (default: ``None``) tuple containing the 2 or 3
coordinates of the ambient chart in terms of which the plot is
performed; if ``None``, all the coordinates of the ambient chart are
considered
- ``mapping`` -- (default: ``None``) differentiable mapping `\Phi`
(instance of
:class:`~sage.geometry.manifolds.diffmapping.DiffMapping`)
providing the link between ``self`` and the ambient chart ``chart``
(cf. above); if ``None``, the ambient chart is supposed to be defined
on the codomain of the curve ``self``.
- ``prange`` -- (default: ``None``) range of the curve parameter for
the plot; if ``None``, the entire parameter range declared during the
curve construction is considered (with -Infinity
replaced by ``-max_value`` and +Infinity by ``max_value``)
- ``include_end_point`` -- (default: ``(True, True)``) determines
whether the end points of ``prange`` are included in the plot
- ``end_point_offset`` -- (default: ``(0.001, 0.001)``) offsets from
the end points when they are not included in the plot: if
``include_end_point[0] == False``, the minimal value of the curve
parameter used for the plot is ``prange[0] + end_point_offset[0]``,
while if ``include_end_point[1] == False``, the maximal value is
``prange[1] - end_point_offset[1]``.
- ``max_value`` -- (default: 8) numerical value substituted to
+Infinity if the latter is the upper bound of the parameter range;
similarly ``-max_value`` is the numerical valued substituted for
-Infinity
- ``parameters`` -- (default: ``None``) dictionary giving the numerical
values of the parameters that may appear in the coordinate expression
of ``self``
- ``color`` -- (default: 'red') color of the drawn curve
- ``style`` -- (default: '-') color of the drawn curve; NB: ``style``
is effective only for 2D plots
- ``thickness`` -- (default: 1) thickness of the drawn curve
- ``plot_points`` -- (default: 75) number of points to plot the curve
- ``label_axes`` -- (default: ``True``) boolean determining whether the
labels of the coordinate axes of ``chart`` shall be added to the
graph; can be set to ``False`` if the graph is 3D and must be
superposed with another graph.
- ``aspect_ratio`` -- (default: 'automatic') aspect ratio of the plot;
the default value ('automatic') applies only for 2D plots; for
3D plots, the default value is ``1`` instead.
OUTPUT:
- a graphic object, either an instance of
:class:`~sage.plot.graphics.Graphics` for a 2D plot (i.e. based on
2 coordinates of ``chart``) or an instance of
:class:`~sage.plot.plot3d.base.Graphics3d` for a 3D plot (i.e.
based on 3 coordinates of ``chart``)
EXAMPLES:
Plot of the lemniscate of Gerono::
sage: R2 = Manifold(2, 'R^2')
sage: X.<x,y> = R2.chart()
sage: R.<t> = RealLine()
sage: c = R2.curve([sin(t), sin(2*t)/2], (t, 0, 2*pi), name='c')
sage: c.plot() # 2D plot
Graphics object consisting of 1 graphics primitive
Plot for a subinterval of the curve's domain::
sage: c.plot(prange=(0,pi))
Graphics object consisting of 1 graphics primitive
Plot with various options::
sage: c.plot(color='green', style=':', thickness=3, aspect_ratio=1)
Graphics object consisting of 1 graphics primitive
Plot via a mapping to another manifold: loxodrome of a sphere viewed
in `\RR^3`::
sage: S2 = Manifold(2, 'S^2')
sage: U = S2.open_subset('U')
sage: XS.<th,ph> = U.chart(r'th:(0,pi):\theta ph:(0,2*pi):\phi')
sage: R3 = Manifold(3, 'R^3')
sage: X3.<x,y,z> = R3.chart()
#.........这里部分代码省略.........
示例3: _graphics
# 需要导入模块: from sage.plot.graphics import Graphics [as 别名]
# 或者: from sage.plot.graphics.Graphics import aspect_ratio [as 别名]
def _graphics(self, plot_curve, ambient_coords, thickness=1,
aspect_ratio='automatic', color='red', style='-',
label_axes=True):
r"""
Plot a 2D or 3D curve in a Cartesian graph with axes labeled by
the ambient coordinates; it is invoked by the methods
:meth:`plot` of
:class:`~sage.manifolds.differentiable.curve.DifferentiableCurve`,
and its subclasses
(:class:`~sage.manifolds.differentiable.integrated_curve.IntegratedCurve`,
:class:`~sage.manifolds.differentiable.integrated_curve.IntegratedAutoparallelCurve`,
and
:class:`~sage.manifolds.differentiable.integrated_curve.IntegratedGeodesic`).
TESTS::
sage: M = Manifold(2, 'R^2')
sage: X.<x,y> = M.chart()
sage: R.<t> = RealLine()
sage: c = M.curve([cos(t), sin(t)], (t, 0, 2*pi), name='c')
sage: graph = c._graphics([[1,2], [3,4]], [x,y])
sage: graph._objects[0].xdata == [1,3]
True
sage: graph._objects[0].ydata == [2,4]
True
sage: graph._objects[0]._options['thickness'] == 1
True
sage: graph._extra_kwds['aspect_ratio'] == 'automatic'
True
sage: graph._objects[0]._options['rgbcolor'] == 'red'
True
sage: graph._objects[0]._options['linestyle'] == '-'
True
sage: l = [r'$'+latex(x)+r'$', r'$'+latex(y)+r'$']
sage: graph._extra_kwds['axes_labels'] == l
True
"""
from sage.plot.graphics import Graphics
from sage.plot.line import line
from sage.manifolds.utilities import set_axes_labels
#
# The plot
#
n_pc = len(ambient_coords)
resu = Graphics()
resu += line(plot_curve, color=color, linestyle=style,
thickness=thickness)
if n_pc == 2: # 2D graphic
resu.set_aspect_ratio(aspect_ratio)
if label_axes:
# We update the dictionary _extra_kwds (options to be passed
# to show()), instead of using the method
# Graphics.axes_labels() since the latter is not robust w.r.t.
# graph addition
resu._extra_kwds['axes_labels'] = [r'$'+latex(pc)+r'$'
for pc in ambient_coords]
else: # 3D graphic
if aspect_ratio == 'automatic':
aspect_ratio = 1
resu.aspect_ratio(aspect_ratio)
if label_axes:
labels = [str(pc) for pc in ambient_coords]
resu = set_axes_labels(resu, *labels)
return resu