summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Gourgoulhon <eric.gourgoulhon@obspm.fr>2015-12-06 22:12:42 +0100
committerEric Gourgoulhon <eric.gourgoulhon@obspm.fr>2015-12-06 22:12:42 +0100
commit7889a5d8dc0fd60d9dcef7edf151177725952961 (patch)
tree0f0cec7e3fa6f74048b36f794e60a672081de003
parentFix doctest error in coord_func_symb.py due to #19312 (update to pynac-0.5.2) (diff)
parentRevert to UniqueRepresentation for topological manifold homsets (diff)
Change in simplify_sqrt_real to cope with the change of != operator induced by #19312 (Sage 6.10.beta7)
-rw-r--r--src/doc/en/reference/manifolds/continuous_map.rst9
-rw-r--r--src/doc/en/reference/manifolds/manifold.rst2
-rw-r--r--src/sage/manifolds/chart.py555
-rw-r--r--src/sage/manifolds/continuous_map.py1829
-rw-r--r--src/sage/manifolds/manifold.py297
-rw-r--r--src/sage/manifolds/manifold_homset.py422
-rw-r--r--src/sage/manifolds/point.py227
-rw-r--r--src/sage/manifolds/utilities.py59
8 files changed, 3399 insertions, 1 deletions
diff --git a/src/doc/en/reference/manifolds/continuous_map.rst b/src/doc/en/reference/manifolds/continuous_map.rst
new file mode 100644
index 00000000..4b67487
--- /dev/null
+++ b/src/doc/en/reference/manifolds/continuous_map.rst
@@ -0,0 +1,9 @@
+Continuous maps
+===============
+
+.. toctree::
+ :maxdepth: 2
+
+ sage/manifolds/manifold_homset
+
+ sage/manifolds/continuous_map
diff --git a/src/doc/en/reference/manifolds/manifold.rst b/src/doc/en/reference/manifolds/manifold.rst
index 19f4354..0466d72 100644
--- a/src/doc/en/reference/manifolds/manifold.rst
+++ b/src/doc/en/reference/manifolds/manifold.rst
@@ -13,3 +13,5 @@ Topological manifolds
chart
scalarfield
+
+ continuous_map
diff --git a/src/sage/manifolds/chart.py b/src/sage/manifolds/chart.py
index 1dd336a..bb1870a 100644
--- a/src/sage/manifolds/chart.py
+++ b/src/sage/manifolds/chart.py
@@ -4,6 +4,8 @@ Coordinate charts
The class :class:`Chart` implements coordinate charts on a topological manifold
over a topological field `K`. The subclass :class:`RealChart` is devoted
to the case `K=\RR`, for which the concept of coordinate range is meaningful.
+Moreover, :class:`RealChart` is endowed with some plotting
+capabilities (cf. method :meth:`~sage.manifolds.chart.RealChart.plot`).
Transition maps between charts are implemented via the class
:class:`CoordChange`.
@@ -1277,6 +1279,9 @@ class RealChart(Chart):
sage: c_cart.valid_coordinates(1,0,2)
True
+ Chart grids can be drawn in 2D or 3D graphics thanks to the method
+ :meth:`plot`.
+
"""
def __init__(self, domain, coordinates='', names=None):
r"""
@@ -1819,6 +1824,556 @@ class RealChart(Chart):
# All tests have been passed:
return True
+ def plot(self, chart=None, ambient_coords=None, mapping=None,
+ fixed_coords=None, ranges=None, max_range=8, nb_values=None,
+ steps=None, parameters=None, color='red', style='-', thickness=1,
+ plot_points=75, label_axes=True):
+ r"""
+ Plot the current chart as a "grid" in a Cartesian graph
+ based on the coordinates of some ambient chart.
+
+ The "grid" is formed by curves along which a chart coordinate
+ varies, the other coordinates being kept fixed; it is drawn in terms of
+ two (2D graphics) or three (3D graphics) coordinates of another chart,
+ called hereafter the *ambient chart*.
+
+ The ambient chart is related to the current chart either by
+ a transition map if both charts are defined on the same manifold, or by
+ the coordinate expression of some continuous map (typically an
+ immersion). In the latter case, the two charts may be defined on two
+ different manifolds.
+
+ INPUT:
+
+ - ``chart`` -- (default: ``None``) the ambient chart (see above); if
+ ``None``, the ambient chart is set to the current chart
+ - ``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``) continuous manifold map (instance
+ of :class:`~sage.manifolds.continuous_map.ContinuousMap`)
+ providing the link between the current chart and the ambient chart
+ (cf. above); if ``None``, both charts are supposed to be defined on
+ the same manifold and related by some transition map (see
+ :meth:`~sage.manifolds.chart.Chart.transition_map`)
+ - ``fixed_coords`` -- (default: ``None``) dictionary with keys the
+ chart coordinates that are not drawn and with values the fixed
+ value of these coordinates; if ``None``, all the coordinates of the
+ current chart are drawn
+ - ``ranges`` -- (default: ``None``) dictionary with keys the coordinates
+ to be drawn and values tuples ``(x_min,x_max)`` specifying the
+ coordinate range for the plot; if ``None``, the entire coordinate
+ range declared during the chart construction is considered (with
+ -Infinity replaced by ``-max_range`` and +Infinity by ``max_range``)
+ - ``max_range`` -- (default: 8) numerical value substituted to
+ +Infinity if the latter is the upper bound of the range of a
+ coordinate for which the plot is performed over the entire coordinate
+ range (i.e. for which no specific plot range has been set in
+ ``ranges``); similarly ``-max_range`` is the numerical valued
+ substituted for -Infinity
+ - ``nb_values`` -- (default: ``None``) either an integer or a dictionary
+ with keys the coordinates to be drawn and values the number of
+ constant values of the coordinate to be considered; if ``nb_values``
+ is a single integer, it represents the number of constant values for
+ all coordinates; if ``nb_values`` is ``None``, it is set to 9 for a
+ 2D plot and to 5 for a 3D plot
+ - ``steps`` -- (default: ``None``) dictionary with keys the coordinates
+ to be drawn and values the step between each constant value of
+ the coordinate; if ``None``, the step is computed from the coordinate
+ range (specified in ``ranges``) and ``nb_values``. On the contrary
+ if the step is provided for some coordinate, the corresponding
+ number of constant values is deduced from it and the coordinate range.
+ - ``parameters`` -- (default: ``None``) dictionary giving the numerical
+ values of the parameters that may appear in the relation between
+ the two coordinate systems
+ - ``color`` -- (default: 'red') either a single color or a dictionary
+ of colors, with keys the coordinates to be drawn, representing the
+ colors of the lines along which the coordinate varies, the other
+ being kept constant; if ``color`` is a single color, it is used for
+ all coordinate lines
+ - ``style`` -- (default: '-') either a single line style or a dictionary
+ of line styles, with keys the coordinates to be drawn, representing
+ the style of the lines along which the coordinate varies, the other
+ being kept constant; if ``style`` is a single style, it is used for
+ all coordinate lines; NB: ``style`` is effective only for 2D plots
+ - ``thickness`` -- (default: 1) either a single line thickness or a
+ dictionary of line thicknesses, with keys the coordinates to be drawn,
+ representing the thickness of the lines along which the coordinate
+ varies, the other being kept constant; if ``thickness`` is a single
+ value, it is used for all coordinate lines
+ - ``plot_points`` -- (default: 75) either a single number of points or
+ a dictionary of integers, with keys the coordinates to be drawn,
+ representing the number of points to plot the lines along which the
+ coordinate varies, the other being kept constant; if ``plot_points``
+ is a single integer, it is used for all coordinate lines
+ - ``label_axes`` -- (default: ``True``) boolean determining whether the
+ labels of the ambient coordinate axes shall be added to the graph;
+ can be set to False if the graph is 3D and must be superposed with
+ another graph.
+
+ OUTPUT:
+
+ - a graphic object, either an instance of
+ :class:`~sage.plot.graphics.Graphics` for a 2D plot (i.e. based on
+ 2 coordinates of the ambient chart) or an instance of
+ :class:`~sage.plot.plot3d.base.Graphics3d` for a 3D plot (i.e.
+ based on 3 coordinates of the ambient chart)
+
+ EXAMPLES:
+
+ Grid of polar coordinates in terms of Cartesian coordinates in the
+ Euclidean plane::
+
+ sage: R2 = Manifold(2, 'R^2', structure='topological') # the Euclidean plane
+ sage: c_cart.<x,y> = R2.chart() # Cartesian coordinates
+ sage: U = R2.open_subset('U', coord_def={c_cart: (y!=0, x<0)}) # the complement of the segment y=0 and x>0
+ sage: c_pol.<r,ph> = U.chart(r'r:(0,+oo) ph:(0,2*pi):\phi') # polar coordinates on U
+ sage: pol_to_cart = c_pol.transition_map(c_cart, [r*cos(ph), r*sin(ph)])
+ sage: g = c_pol.plot(c_cart)
+ sage: type(g)
+ <class 'sage.plot.graphics.Graphics'>
+ sage: show(g) # graphical display
+
+ .. PLOT::
+
+ R2 = Manifold(2, 'R^2', structure='topological')
+ c_cart = R2.chart('x y'); x, y = c_cart[:]
+ U = R2.open_subset('U', coord_def={c_cart: (y!=0, x<0)})
+ c_pol = U.chart(r'r:(0,+oo) ph:(0,2*pi):\phi'); r, ph = c_pol[:]
+ pol_to_cart = c_pol.transition_map(c_cart, [r*cos(ph), r*sin(ph)])
+ g = c_pol.plot(c_cart)
+ sphinx_plot(g)
+
+ Call with non-default values::
+
+ sage: g = c_pol.plot(c_cart, ranges={ph:(pi/4,pi)}, nb_values={r:7, ph:17},
+ ....: color={r:'red', ph:'green'}, style={r:'-', ph:'--'})
+
+ .. PLOT::
+
+ R2 = Manifold(2, 'R^2', structure='topological')
+ c_cart = R2.chart('x y'); x, y = c_cart[:]
+ U = R2.open_subset('U', coord_def={c_cart: (y!=0, x<0)})
+ c_pol = U.chart(r'r:(0,+oo) ph:(0,2*pi):\phi'); r, ph = c_pol[:]
+ pol_to_cart = c_pol.transition_map(c_cart, [r*cos(ph), r*sin(ph)])
+ g = c_pol.plot(c_cart, ranges={ph:(pi/4,pi)}, nb_values={r:7, ph:17}, \
+ color={r:'red', ph:'green'}, style={r:'-', ph:'--'})
+ sphinx_plot(g)
+
+ A single coordinate line can be drawn::
+
+ sage: g = c_pol.plot(c_cart, fixed_coords={r: 2}) # draw a circle of radius r=2
+
+ .. PLOT::
+
+ R2 = Manifold(2, 'R^2', structure='topological')
+ c_cart = R2.chart('x y'); x, y = c_cart[:]
+ U = R2.open_subset('U', coord_def={c_cart: (y!=0, x<0)})
+ c_pol = U.chart(r'r:(0,+oo) ph:(0,2*pi):\phi'); r, ph = c_pol[:]
+ pol_to_cart = c_pol.transition_map(c_cart, [r*cos(ph), r*sin(ph)])
+ g = c_pol.plot(c_cart, fixed_coords={r: 2})
+ sphinx_plot(g)
+
+ ::
+
+ sage: g = c_pol.plot(c_cart, fixed_coords={ph: pi/4}) # draw a segment at phi=pi/4
+
+ .. PLOT::
+
+ R2 = Manifold(2, 'R^2', structure='topological')
+ c_cart = R2.chart('x y'); x, y = c_cart[:]
+ U = R2.open_subset('U', coord_def={c_cart: (y!=0, x<0)})
+ c_pol = U.chart(r'r:(0,+oo) ph:(0,2*pi):\phi'); r, ph = c_pol[:]
+ pol_to_cart = c_pol.transition_map(c_cart, [r*cos(ph), r*sin(ph)])
+ g = c_pol.plot(c_cart, fixed_coords={ph: pi/4})
+ sphinx_plot(g)
+
+ A chart can be plotted in terms of itself, resulting in a rectangular
+ grid::
+
+ sage: g = c_cart.plot() # equivalent to c_cart.plot(c_cart)
+ sage: show(g) # a rectangular grid
+
+ .. PLOT::
+
+ R2 = Manifold(2, 'R^2', structure='topological')
+ c_cart = R2.chart('x y'); x, y = c_cart[:]
+ g = c_cart.plot()
+ sphinx_plot(g)
+
+ An example with the ambient chart given by the coordinate expression of
+ some manifold map: 3D plot of the stereographic charts on the
+ 2-sphere::
+
+ sage: S2 = Manifold(2, 'S^2', structure='topological') # the 2-sphere
+ sage: U = S2.open_subset('U') ; V = S2.open_subset('V') # complement of the North and South pole, respectively
+ sage: S2.declare_union(U,V)
+ sage: c_xy.<x,y> = U.chart() # stereographic coordinates from the North pole
+ sage: c_uv.<u,v> = V.chart() # stereographic coordinates from the South pole
+ sage: xy_to_uv = c_xy.transition_map(c_uv, (x/(x^2+y^2), y/(x^2+y^2)),
+ ....: intersection_name='W', restrictions1= x^2+y^2!=0,
+ ....: restrictions2= u^2+v^2!=0)
+ sage: uv_to_xy = xy_to_uv.inverse()
+ sage: R3 = Manifold(3, 'R^3', structure='topological') # the Euclidean space R^3
+ sage: c_cart.<X,Y,Z> = R3.chart() # Cartesian coordinates on R^3
+ sage: Phi = S2.continuous_map(R3, {(c_xy, c_cart): [2*x/(1+x^2+y^2),
+ ....: 2*y/(1+x^2+y^2), (x^2+y^2-1)/(1+x^2+y^2)],
+ ....: (c_uv, c_cart): [2*u/(1+u^2+v^2),
+ ....: 2*v/(1+u^2+v^2), (1-u^2-v^2)/(1+u^2+v^2)]},
+ ....: name='Phi', latex_name=r'\Phi') # Embedding of S^2 in R^3
+ sage: g = c_xy.plot(c_cart, mapping=Phi)
+ sage: show(g) # 3D graphic display
+ sage: type(g)
+ <class 'sage.plot.plot3d.base.Graphics3dGroup'>
+
+ The same plot without the (X,Y,Z) axes labels::
+
+ sage: g = c_xy.plot(c_cart, mapping=Phi, label_axes=False)
+
+ The North and South stereographic charts on the same plot::
+
+ sage: g2 = c_uv.plot(c_cart, mapping=Phi, color='green')
+ sage: show(g+g2)
+
+ South stereographic chart drawned in terms of the North one (we split
+ the plot in four parts to avoid the singularity at (u,v)=(0,0))::
+
+ sage: W = U.intersection(V) # the subset common to both charts
+ sage: c_uvW = c_uv.restrict(W) # chart (W,(u,v))
+ sage: gSN1 = c_uvW.plot(c_xy, ranges={u:[-6.,-0.02], v:[-6.,-0.02]})
+ sage: gSN2 = c_uvW.plot(c_xy, ranges={u:[-6.,-0.02], v:[0.02,6.]})
+ sage: gSN3 = c_uvW.plot(c_xy, ranges={u:[0.02,6.], v:[-6.,-0.02]})
+ sage: gSN4 = c_uvW.plot(c_xy, ranges={u:[0.02,6.], v:[0.02,6.]})
+ sage: show(gSN1+gSN2+gSN3+gSN4, xmin=-1.5, xmax=1.5, ymin=-1.5, ymax=1.5)
+
+ .. PLOT::
+
+ S2 = Manifold(2, 'S^2', structure='topological')
+ U = S2.open_subset('U'); V = S2.open_subset('V'); S2.declare_union(U,V)
+ c_xy = U.chart('x y'); x, y = c_xy[:]
+ c_uv = V.chart('u v'); u, v = c_uv[:]
+ xy_to_uv = c_xy.transition_map(c_uv, (x/(x**2+y**2), y/(x**2+y**2)), \
+ intersection_name='W', restrictions1= x**2+y**2!=0, \
+ restrictions2= u**2+v**2!=0)
+ uv_to_xy = xy_to_uv.inverse()
+ c_uvW = c_uv.restrict(U.intersection(V))
+ gSN1 = c_uvW.plot(c_xy, ranges={u:[-6.,-0.02], v:[-6.,-0.02]})
+ gSN2 = c_uvW.plot(c_xy, ranges={u:[-6.,-0.02], v:[0.02,6.]})
+ gSN3 = c_uvW.plot(c_xy, ranges={u:[0.02,6.], v:[-6.,-0.02]})
+ gSN4 = c_uvW.plot(c_xy, ranges={u:[0.02,6.], v:[0.02,6.]})
+ g = gSN1+gSN2+gSN3+gSN4; g.set_axes_range(-1.5, 1.5, -1.5, 1.5)
+ sphinx_plot(g)
+
+ The coordinate line u=1 (red) and the coordinate line v=1 (green) on
+ the same plot::
+
+ sage: gu1 = c_uvW.plot(c_xy, fixed_coords={u: 1}, max_range=20, plot_points=300)
+ sage: gv1 = c_uvW.plot(c_xy, fixed_coords={v: 1}, max_range=20, plot_points=300, color='green')
+ sage: show(gu1+gv1)
+
+ .. PLOT::
+
+ S2 = Manifold(2, 'S^2', structure='topological')
+ U = S2.open_subset('U'); V = S2.open_subset('V'); S2.declare_union(U,V)
+ c_xy = U.chart('x y'); x, y = c_xy[:]
+ c_uv = V.chart('u v'); u, v = c_uv[:]
+ xy_to_uv = c_xy.transition_map(c_uv, (x/(x**2+y**2), y/(x**2+y**2)), \
+ intersection_name='W', restrictions1= x**2+y**2!=0, \
+ restrictions2= u**2+v**2!=0)
+ uv_to_xy = xy_to_uv.inverse()
+ c_uvW = c_uv.restrict(U.intersection(V))
+ gu1 = c_uvW.plot(c_xy, fixed_coords={u: 1}, max_range=20, plot_points=300)
+ gv1 = c_uvW.plot(c_xy, fixed_coords={v: 1}, max_range=20, plot_points=300, color='green')
+ sphinx_plot(gu1+gv1)
+
+ Note that we have set ``max_range=20`` to have a wider range for the
+ coordinates u and v, i.e. to have [-20,20] instead of the default
+ [-8,8].
+
+ A 3-dimensional chart plotted in terms of itself results in a 3D
+ rectangular grid::
+
+ sage: g = c_cart.plot() # equivalent to c_cart.plot(c_cart)
+ sage: show(g) # a 3D mesh cube
+
+ A 4-dimensional chart plotted in terms of itself (the plot is
+ performed for at most 3 coordinates, which must be specified via
+ the argument ``ambient_coords``)::
+
+ sage: M = Manifold(4, 'M', structure='topological')
+ sage: X.<t,x,y,z> = M.chart()
+ sage: g = X.plot(ambient_coords=(t,x,y)) # the coordinate z is not depicted
+ sage: show(g) # a 3D mesh cube
+ sage: g = X.plot(ambient_coords=(t,y)) # the coordinates x and z are not depicted
+ sage: show(g) # a 2D mesh square
+
+ .. PLOT::
+
+ M = Manifold(4, 'M', structure='topological')
+ X = M.chart('t x y z'); t,x,y,z = X[:]
+ g = X.plot(ambient_coords=(t,y))
+ sphinx_plot(g)
+
+ """
+ from sage.misc.functional import numerical_approx
+ from sage.plot.graphics import Graphics
+ from sage.plot.line import line
+ from sage.manifolds.continuous_map import ContinuousMap
+ from utilities import set_axes_labels
+
+ def _plot_xx_list(xx_list, rem_coords, ranges, steps, nb_values):
+ r"""
+ Helper function to plot the coordinate grid.
+ """
+ coord = rem_coords[0]
+ xmin = ranges[coord][0]
+ sx = steps[coord]
+ resu = []
+ for xx in xx_list:
+ xc = xmin
+ for i in range(nb_values[coord]):
+ nxx = list(xx)
+ nxx[self._xx.index(coord)] = xc
+ resu.append(nxx)
+ xc += sx
+ if len(rem_coords) == 1:
+ return resu
+ else:
+ rem_coords.remove(coord)
+ return _plot_xx_list(resu, rem_coords, ranges, steps,
+ nb_values)
+
+ if chart is None:
+ chart = self
+ elif not isinstance(chart, Chart):
+ raise TypeError("the argument 'chart' must be a coordinate chart")
+ #
+ # 1/ Determination of the relation between self and chart
+ # ------------------------------------------------------------
+ nc = self._manifold.dimension()
+ if chart is self:
+ transf = self.multifunction(*(self._xx))
+ if nc > 3:
+ if ambient_coords is None:
+ raise TypeError("the argument 'ambient_coords' must be " +
+ "provided")
+ if len(ambient_coords) > 3:
+ raise ValueError("too many ambient coordinates")
+ fixed_coords = {}
+ for coord in self._xx:
+ if coord not in ambient_coords:
+ fixed_coords[coord] = 0
+ else:
+ transf = None # to be the MultiCoordFunction object relating self
+ # to the ambient chart
+ if mapping is None:
+ if not self._domain.is_subset(chart._domain):
+ raise ValueError("the domain of {} is not ".format(self) +
+ "included in that of {}".format(chart))
+ coord_changes = chart._domain._coord_changes
+ for chart_pair in coord_changes:
+ if chart_pair == (self, chart):
+ transf = coord_changes[chart_pair]._transf
+ break
+ else:
+ # Search for a subchart
+ for chart_pair in coord_changes:
+ for schart in chart._subcharts:
+ if chart_pair == (self, schart):
+ transf = coord_changes[chart_pair]._transf
+ else:
+ if not isinstance(mapping, ContinuousMap):
+ raise TypeError("the argument 'mapping' must be a " +
+ "continuous manifold map")
+ if not self._domain.is_subset(mapping._domain):
+ raise ValueError("the domain of {} is not ".format(self) +
+ "included in that of {}".format(mapping))
+ if not chart._domain.is_subset(mapping._codomain):
+ raise ValueError("the domain of {} is not ".format(chart) +
+ "included in the codomain of {}".format(
+ mapping))
+ try:
+ transf = mapping.coord_functions(chart1=self, chart2=chart)
+ except ValueError:
+ pass
+ if transf is None:
+ raise ValueError("no relation has been found between " +
+ "{} and {}".format(self, chart))
+ #
+ # 2/ Treatment of input parameters
+ # -----------------------------
+ if fixed_coords is None:
+ coords = self._xx
+ else:
+ fixed_coord_list = fixed_coords.keys()
+ coords = []
+ for coord in self._xx:
+ if coord not in fixed_coord_list:
+ coords.append(coord)
+ coords = tuple(coords)
+ if ambient_coords is None:
+ ambient_coords = chart._xx
+ elif not isinstance(ambient_coords, tuple):
+ ambient_coords = tuple(ambient_coords)
+ nca = len(ambient_coords)
+ if nca != 2 and nca !=3:
+ raise ValueError("bad number of ambient coordinates: {}".format(nca))
+ if ranges is None:
+ ranges = {}
+ ranges0 = {}
+ for coord in coords:
+ if coord in ranges:
+ ranges0[coord] = (numerical_approx(ranges[coord][0]),
+ numerical_approx(ranges[coord][1]))
+ else:
+ bounds = self._bounds[self._xx.index(coord)]
+ if bounds[0][0] == -Infinity:
+ xmin = numerical_approx(-max_range)
+ elif bounds[0][1]:
+ xmin = numerical_approx(bounds[0][0])
+ else:
+ xmin = numerical_approx(bounds[0][0] + 1.e-3)
+ if bounds[1][0] == Infinity:
+ xmax = numerical_approx(max_range)
+ elif bounds[1][1]:
+ xmax = numerical_approx(bounds[1][0])
+ else:
+ xmax = numerical_approx(bounds[1][0] - 1.e-3)
+ ranges0[coord] = (xmin, xmax)
+ ranges = ranges0
+ if nb_values is None:
+ if nca == 2: # 2D plot
+ nb_values = 9
+ else: # 3D plot
+ nb_values = 5
+ if not isinstance(nb_values, dict):
+ nb_values0 = {}
+ for coord in coords:
+ nb_values0[coord] = nb_values
+ nb_values = nb_values0
+ if steps is None:
+ steps = {}
+ for coord in coords:
+ if coord not in steps:
+ steps[coord] = (ranges[coord][1] - ranges[coord][0])/ \
+ (nb_values[coord]-1)
+ else:
+ nb_values[coord] = 1 + int(
+ (ranges[coord][1] - ranges[coord][0])/ steps[coord])
+ if not isinstance(color, dict):
+ color0 = {}
+ for coord in coords:
+ color0[coord] = color
+ color = color0
+ if not isinstance(style, dict):
+ style0 = {}
+ for coord in coords:
+ style0[coord] = style
+ style = style0
+ if not isinstance(thickness, dict):
+ thickness0 = {}
+ for coord in coords:
+ thickness0[coord] = thickness
+ thickness = thickness0
+ if not isinstance(plot_points, dict):
+ plot_points0 = {}
+ for coord in coords:
+ plot_points0[coord] = plot_points
+ plot_points = plot_points0
+ #
+ # 3/ Plots
+ # -----
+ xx0 = [0] * nc
+ if fixed_coords is not None:
+ if len(fixed_coords) != nc - len(coords):
+ raise ValueError("bad number of fixed coordinates")
+ for fc, val in fixed_coords.iteritems():
+ xx0[self._xx.index(fc)] = val
+ ind_a = [chart._xx.index(ac) for ac in ambient_coords]
+ resu = Graphics()
+ for coord in coords:
+ color_c, style_c = color[coord], style[coord]
+ thickness_c = thickness[coord]
+ rem_coords = list(coords)
+ rem_coords.remove(coord)
+ xx_list = [xx0]
+ if len(rem_coords) >= 1:
+ xx_list = _plot_xx_list(xx_list, rem_coords, ranges, steps,
+ nb_values)
+ xmin, xmax = ranges[coord]
+ nbp = plot_points[coord]
+ dx = (xmax - xmin) / (nbp-1)
+ ind_coord = self._xx.index(coord)
+ for xx in xx_list:
+ curve = []
+ first_invalid = False # initialization
+ xc = xmin
+ xp = list(xx)
+ if parameters is None:
+ for i in range(nbp):
+ xp[ind_coord] = xc
+ if self.valid_coordinates(*xp, tolerance=1e-13):
+ yp = transf(*xp, simplify=False)
+ curve.append( [numerical_approx(yp[j])
+ for j in ind_a] )
+ first_invalid = True # next invalid point will be
+ # the first one
+ else:
+ if first_invalid:
+ # the curve is stopped at previous point and
+ # added to the graph:
+ resu += line(curve, color=color_c,
+ linestyle=style_c,
+ thickness=thickness_c)
+ curve = [] # a new curve will start at the
+ # next valid point
+ first_invalid = False # next invalid point will not