本文整理汇总了Python中sage.plot.line.line函数的典型用法代码示例。如果您正苦于以下问题:Python line函数的具体用法?Python line怎么用?Python line使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了line函数的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: plot_cluster_fan_stereographically
def plot_cluster_fan_stereographically(self, northsign=1, north=None, right=None, colors=None):
from sage.plot.graphics import Graphics
from sage.plot.point import point
from sage.misc.flatten import flatten
from sage.plot.line import line
from sage.misc.functional import norm
if self.rk !=3:
raise ValueError("Can only stereographically project fans in 3d.")
if not self.is_finite() and self._depth == infinity:
raise ValueError("For infinite algebras you must specify the depth.")
if north == None:
if self.is_affine():
north = vector(self.delta())
else:
north = vector( (-1,-1,-1) )
if right == None:
if self.is_affine():
right = vector(self.gamma())
else:
right = vector( (1,0,0) )
if colors == None:
colors = dict([(0,'red'),(1,'green'),(2,'blue'),(3,'cyan'),(4,'yellow')])
G = Graphics()
roots = list(self.g_vectors())
compatible = []
while roots:
x = roots.pop()
for y in roots:
if self.compatibility_degree(x,y) == 0:
compatible.append((x,y))
for (u,v) in compatible:
G += _stereo_arc(vector(u),vector(v),vector(u+v),north=northsign*north,right=right,thickness=0.5,color='black')
for i in range(3):
orbit = self.ith_orbit(i)
for j in orbit:
G += point(_stereo_coordinates(vector(orbit[j]),north=northsign*north,right=right),color=colors[i],zorder=len(G))
if self.is_affine():
tube_vectors = map(vector,flatten(self.affine_tubes()))
for v in tube_vectors:
G += point(_stereo_coordinates(v,north=northsign*north,right=right),color=colors[3],zorder=len(G))
if north != vector(self.delta()):
G += _stereo_arc(tube_vectors[0],tube_vectors[1],vector(self.delta()),north=northsign*north,right=right,thickness=2,color=colors[4],zorder=0)
else:
# FIXME: refactor this before publishing
tube_projections = [
_stereo_coordinates(v,north=northsign*north,right=right)
for v in tube_vectors ]
t=min((G.get_minmax_data()['xmax'],G.get_minmax_data()['ymax']))
G += line([tube_projections[0],tube_projections[0]+t*(_normalize(tube_projections[0]-tube_projections[1]))],thickness=2,color=colors[4],zorder=0)
G += line([tube_projections[1],tube_projections[1]+t*(_normalize(tube_projections[1]-tube_projections[0]))],thickness=2,color=colors[4],zorder=0)
G.set_aspect_ratio(1)
G._show_axes = False
return G
开发者ID:Etn40ff,项目名称:cluster_seed_reborn,代码行数:58,代码来源:tropical_cluster_algebra_g.py
示例2: _arc
def _arc(p,q,s,**kwds):
#rewrite this to use polar_plot and get points to do filled triangles
from sage.misc.functional import det
from sage.plot.line import line
from sage.misc.functional import norm
from sage.symbolic.all import pi
from sage.plot.arc import arc
p,q,s = map( lambda x: vector(x), [p,q,s])
# to avoid running into division by 0 we set to be colinear vectors that are
# almost colinear
if abs(det(matrix([p-s,q-s])))<0.01:
return line((p,q),**kwds)
(cx,cy)=var('cx','cy')
equations=[
2*cx*(s[0]-p[0])+2*cy*(s[1]-p[1]) == s[0]**2+s[1]**2-p[0]**2-p[1]**2,
2*cx*(s[0]-q[0])+2*cy*(s[1]-q[1]) == s[0]**2+s[1]**2-q[0]**2-q[1]**2
]
c = vector( [solve( equations, (cx,cy), solution_dict=True )[0][i] for i in [cx,cy]] )
r = norm(p-c)
a_p,a_q,a_s = map( _to_angle, [p-c,q-c,s-c])
angles = [a_p,a_q,a_s]
angles.sort()
if a_s == angles[0]:
return arc( c, r, angle=angles[2], sector=(0,2*pi-angles[2]+angles[1]), **kwds)
if a_s == angles[1]:
return arc( c, r, angle=angles[0], sector=(0,angles[2]-angles[0]), **kwds)
if a_s == angles[2]:
return arc( c, r, angle=angles[1], sector=(0,2*pi-angles[1]+angles[0]), **kwds)
开发者ID:Etn40ff,项目名称:finite_type_cyclic_experiments,代码行数:34,代码来源:find_sortable_cones.py
示例3: plot_y
def plot_y(self, plot_points=128, **kwds):
r"""Plot the y-part of the path in the complex y-plane.
Additional arguments and keywords are passed to
``matplotlib.pyplot.plot``.
Parameters
----------
N : int
The number of interpolating points used to plot.
t0 : double
Starting t-value in [0,1].
t1 : double
Ending t-value in [0,1].
Returns
-------
plt : Sage plot.
A plot of the complex y-projection of the path.
"""
s = numpy.linspace(0, 1, plot_points, dtype=double)
vals = numpy.array([self.get_y(si)[0] for si in s], dtype=complex)
pts = [(real_part(y), imag_part(y)) for y in vals]
plt = line(pts, **kwds)
return plt
开发者ID:collijk,项目名称:abelfunctions,代码行数:26,代码来源:riemann_surface_path.py
示例4: plot_n_matrices_eigenvectors
def plot_n_matrices_eigenvectors(self, n, side='right', color_index=0, draw_line=False):
r"""
INPUT:
- ``n`` -- integer, length
- ``side`` -- ``'left'`` or ``'right'``, drawing left or right
eigenvectors
- ``color_index`` -- 0 for first letter, -1 for last letter
- ``draw_line`` -- boolean
EXAMPLES::
sage: from slabbe.matrix_cocycle import cocycles
sage: ARP = cocycles.ARP()
sage: G = ARP.plot_n_matrices_eigenvectors(2)
"""
from sage.plot.graphics import Graphics
from sage.plot.point import point
from sage.plot.line import line
from sage.plot.text import text
from sage.plot.colors import hue
from sage.modules.free_module_element import vector
from .matrices import M3to2
R = self.n_matrices_eigenvectors(n)
L = [(w, M3to2*(a/sum(a)), M3to2*(b/sum(b))) for (w,a,b) in R]
G = Graphics()
alphabet = self._language._alphabet
color_ = dict( (letter, hue(i/float(len(alphabet)))) for i,letter in
enumerate(alphabet))
for letter in alphabet:
L_filtered = [(w,p1,p2) for (w,p1,p2) in L if w[color_index] == letter]
words,rights,lefts = zip(*L_filtered)
if side == 'right':
G += point(rights, color=color_[letter], legend_label=letter)
elif side == 'left':
G += point(lefts, color=color_[letter], legend_label=letter)
else:
raise ValueError("side(=%s) should be left or right" % side)
if draw_line:
for (a,b) in L:
G += line([a,b], color='black', linestyle=":")
G += line([M3to2*vector(a) for a in [(1,0,0), (0,1,0), (0,0,1), (1,0,0)]])
title = "%s eigenvectors, colored by letter w[%s] of cylinder w" % (side, color_index)
G += text(title, (0.5, 1.05), axis_coords=True)
G.axes(False)
return G
开发者ID:seblabbe,项目名称:slabbe,代码行数:47,代码来源:matrix_cocycle.py
示例5: show
def show(self, boundary=True, **options):
r"""
Plot ``self``.
EXAMPLES::
sage: HyperbolicPlane().UHP().get_geodesic(0, 1).show()
Graphics object consisting of 2 graphics primitives
"""
opts = {'axes': False, 'aspect_ratio': 1}
opts.update(self.graphics_options())
opts.update(options)
end_1, end_2 = [CC(k.coordinates()) for k in self.endpoints()]
bd_1, bd_2 = [CC(k.coordinates()) for k in self.ideal_endpoints()]
if (abs(real(end_1) - real(end_2)) < EPSILON) \
or CC(infinity) in [end_1, end_2]: #on same vertical line
# If one of the endpoints is infinity, we replace it with a
# large finite point
if end_1 == CC(infinity):
end_1 = (real(end_2), (imag(end_2) + 10))
end_2 = (real(end_2), imag(end_2))
elif end_2 == CC(infinity):
end_2 = (real(end_1), (imag(end_1) + 10))
end_1 = (real(end_1), imag(end_1))
from sage.plot.line import line
pic = line((end_1, end_2), **opts)
if boundary:
cent = min(bd_1, bd_2)
bd_dict = {'bd_min': cent - 3, 'bd_max': cent + 3}
bd_pic = self._model.get_background_graphic(**bd_dict)
pic = bd_pic + pic
return pic
else:
center = (bd_1 + bd_2)/2 # Circle center
radius = abs(bd_1 - bd_2)/2
theta1 = CC(end_1 - center).arg()
theta2 = CC(end_2 - center).arg()
if abs(theta1 - theta2) < EPSILON:
theta2 += pi
[theta1, theta2] = sorted([theta1, theta2])
from sage.calculus.var import var
from sage.plot.plot import parametric_plot
x = var('x')
pic = parametric_plot((radius*cos(x) + real(center),
radius*sin(x) + imag(center)),
(x, theta1, theta2), **opts)
if boundary:
# We want to draw a segment of the real line. The
# computations below compute the projection of the
# geodesic to the real line, and then draw a little
# to the left and right of the projection.
shadow_1, shadow_2 = [real(k) for k in [end_1, end_2]]
midpoint = (shadow_1 + shadow_2)/2
length = abs(shadow_1 - shadow_2)
bd_dict = {'bd_min': midpoint - length, 'bd_max': midpoint +
length}
bd_pic = self._model.get_background_graphic(**bd_dict)
pic = bd_pic + pic
return pic
开发者ID:rgbkrk,项目名称:sage,代码行数:59,代码来源:hyperbolic_geodesic.py
示例6: piecewise_linear_image
def piecewise_linear_image(A,B):
# Jumps up and down going around circle, not used
v = circle_drops(A,B)
G = Graphics()
w = [(Rational(i)/len(v), j) for i,j in enumerate(v)]
for pt in w:
G += line([(pt[0],pt[1]),(pt[0]+Rational(1)/len(w),pt[1])])
return G
开发者ID:mrubinst,项目名称:lmfdb,代码行数:8,代码来源:plot.py
示例7: legend_3d
def legend_3d(hyperplane_arrangement, hyperplane_colors, length):
r"""
Create plot of a 3d legend for an arrangement of planes in 3-space. The
``length`` parameter determines whether short or long labels are used in
the legend.
INPUT:
- ``hyperplane_arrangement`` -- a hyperplane arrangement
- ``hyperplane_colors`` -- list of colors
- ``length`` -- either ``'short'`` or ``'long'``
OUTPUT:
- A graphics object.
EXAMPLES::
sage: a = hyperplane_arrangements.semiorder(3)
sage: from sage.geometry.hyperplane_arrangement.plot import legend_3d
sage: legend_3d(a, list(colors.values())[:6],length='long')
Graphics object consisting of 6 graphics primitives
sage: b = hyperplane_arrangements.semiorder(4)
sage: c = b.essentialization()
sage: legend_3d(c, list(colors.values())[:12], length='long')
Graphics object consisting of 12 graphics primitives
sage: legend_3d(c, list(colors.values())[:12], length='short')
Graphics object consisting of 12 graphics primitives
sage: p = legend_3d(c, list(colors.values())[:12], length='short')
sage: p.set_legend_options(ncol=4)
sage: type(p)
<class 'sage.plot.graphics.Graphics'>
"""
if hyperplane_arrangement.dimension() != 3:
raise ValueError('arrangements must be in 3-space')
hyps = hyperplane_arrangement.hyperplanes()
N = len(hyperplane_arrangement)
if length == 'short':
labels = [' ' + str(i) for i in range(N)]
else:
labels = [' ' + hyps[i]._repr_linear(include_zero=False) for i in
range(N)]
p = Graphics()
for i in range(N):
p += line([(0,0),(0,0)], color=hyperplane_colors[i], thickness=8,
legend_label=labels[i], axes=False)
p.set_legend_options(title='Hyperplanes', loc='center', labelspacing=0.4,
fancybox=True, font_size='x-large', ncol=2)
p.legend(True)
return p
开发者ID:saraedum,项目名称:sage-renamed,代码行数:55,代码来源:plot.py
示例8: plot
def plot(self, **kwargs):
"""
Plot this Newton polygon.
.. NOTE::
All usual rendering options (color, thickness, etc.) are available.
EXAMPLES:
sage: from sage.geometry.newton_polygon import NewtonPolygon
sage: NP = NewtonPolygon([ (0,0), (1,1), (2,6) ])
sage: polygon = NP.plot()
"""
vertices = self.vertices()
if len(vertices) == 0:
from sage.plot.graphics import Graphics
return Graphics()
else:
from sage.plot.line import line
(xstart,ystart) = vertices[0]
(xend,yend) = vertices[-1]
if self.last_slope() is Infinity:
return line([(xstart, ystart+1), (xstart,ystart+0.5)], linestyle="--", **kwargs) \
+ line([(xstart, ystart+0.5)] + vertices + [(xend, yend+0.5)], **kwargs) \
+ line([(xend, yend+0.5), (xend, yend+1)], linestyle="--", **kwargs)
else:
return line([(xstart, ystart+1), (xstart,ystart+0.5)], linestyle="--", **kwargs) \
+ line([(xstart, ystart+0.5)] + vertices + [(xend+0.5, yend + 0.5*self.last_slope())], **kwargs) \
+ line([(xend+0.5, yend + 0.5*self.last_slope()), (xend+1, yend+self.last_slope())], linestyle="--", **kwargs)
开发者ID:Findstat,项目名称:sage,代码行数:30,代码来源:newton_polygon.py
示例9: get_background_graphic
def get_background_graphic(self, **bdry_options):
r"""
Return a graphic object that makes the model easier to visualize.
For the upper half space, the background object is the ideal boundary.
EXAMPLES::
sage: hp = HyperbolicPlane().UHP().get_background_graphic()
"""
from sage.plot.line import line
bd_min = bdry_options.get('bd_min', -5)
bd_max = bdry_options.get('bd_max', 5)
return line(((bd_min, 0), (bd_max, 0)), color='black')
开发者ID:mcognetta,项目名称:sage,代码行数:13,代码来源:hyperbolic_model.py
示例10: show
def show(self, boundary=True, **options):
r"""
Plot ``self``.
EXAMPLES:
First some lines::
sage: PD = HyperbolicPlane().PD()
sage: PD.get_geodesic(0, 1).show()
Graphics object consisting of 2 graphics primitives
sage: PD.get_geodesic(0, 0.3+0.8*I).show()
Graphics object consisting of 2 graphics primitives
Then some generic geodesics::
sage: PD.get_geodesic(-0.5, 0.3+0.4*I).show()
Graphics object consisting of 2 graphics primitives
sage: PD.get_geodesic(-1, exp(3*I*pi/7)).show(linestyle="dashed", color="red")
Graphics object consisting of 2 graphics primitives
sage: PD.get_geodesic(exp(2*I*pi/11), exp(1*I*pi/11)).show(thickness=6, color="orange")
Graphics object consisting of 2 graphics primitives
"""
opts = {'axes': False, 'aspect_ratio': 1}
opts.update(self.graphics_options())
opts.update(options)
end_1, end_2 = [CC(k.coordinates()) for k in self.endpoints()]
bd_1, bd_2 = [CC(k.coordinates()) for k in self.ideal_endpoints()]
# Check to see if it's a line
if abs(bd_1 + bd_2) < EPSILON:
pic = line([end_1, end_2], **opts)
else:
# If we are here, we know it's not a line
# So we compute the center and radius of the circle
invdet = RR.one() / (real(bd_1)*imag(bd_2) - real(bd_2)*imag(bd_1))
centerx = (imag(bd_2) - imag(bd_1)) * invdet
centery = (real(bd_1) - real(bd_2)) * invdet
center = centerx + I * centery
radius = RR(abs(bd_1 - center))
# Now we calculate the angles for the arc
theta1 = CC(end_1 - center).arg()
theta2 = CC(end_2 - center).arg()
theta1, theta2 = sorted([theta1, theta2])
# Make sure the sector is inside the disk
if theta2 - theta1 > pi:
theta1 += 2 * pi
pic = arc((centerx, centery), radius,
sector=(theta1, theta2), **opts)
if boundary:
pic += self._model.get_background_graphic()
return pic
开发者ID:BlairArchibald,项目名称:sage,代码行数:51,代码来源:hyperbolic_geodesic.py
示例11: plot2d
def plot2d(self,depth=None):
# FIXME: refactor this before publishing
from sage.plot.line import line
from sage.plot.graphics import Graphics
if self._n !=2:
raise ValueError("Can only 2d plot fans.")
if depth == None:
depth = self._depth
if not self.is_finite() and depth==infinity:
raise ValueError("For infinite algebras you must specify the depth.")
colors = dict([(0,'red'),(1,'green')])
G = Graphics()
for i in range(2):
orbit = self.ith_orbit(i,depth=depth)
for j in orbit:
G += line([(0,0),vector(orbit[j])],color=colors[i],thickness=0.5, zorder=2*j+1)
G.set_aspect_ratio(1)
G._show_axes = False
return G
开发者ID:Etn40ff,项目名称:level_zero,代码行数:21,代码来源:tropical_cluster_algebra.py
示例12: plot
def plot(self, m, pointsize=100, thickness=3, axes=False):
r"""
Return 2d graphics object contained in the primal box [-m,m]^d.
INPUT:
- ``pointsize``, integer (default:``100``),
- ``thickness``, integer (default:``3``),
- ``axes``, bool (default:``False``),
EXAMPLES::
sage: from slabbe import BondPercolationSample
sage: S = BondPercolationSample(0.5,2)
sage: S.plot(2) # optional long
It works in 3d!!::
sage: S = BondPercolationSample(0.5,3)
sage: S.plot(3, pointsize=10, thickness=1) # optional long
Graphics3d Object
"""
s = ""
s += "\\begin{tikzpicture}\n"
s += "[inner sep=0pt,thick,\n"
s += "reddot/.style={fill=red,draw=red,circle,minimum size=5pt}]\n"
s += "\\clip %s rectangle %s;\n" % ((-m-.4,-m-.4), (m+.4,m+.4))
G = Graphics()
for u in self.cluster_in_box(m+1):
G += point(u, color='blue', size=pointsize)
for (u,v) in self.edges_in_box(m+1):
G += line((u,v), thickness=thickness, alpha=0.8)
G += text("p=%.3f" % self._p, (0.5,1.03), axis_coords=True, color='black')
G += circle((0,0), 0.5, color='red', thickness=thickness)
if self._dimension == 2:
G.axes(axes)
return G
开发者ID:seblabbe,项目名称:slabbe,代码行数:38,代码来源:bond_percolation.py
示例13: list_plot
def list_plot(cls, points, **kwargs):
r"""
Returns a sage figure containing a list plot.
INPUT:
- ``cls`` -- class on which the function is invoked.
- ``points`` -- list or tuple of 2D or 3D points to be plotted.
- ``joined`` -- boolean (default: False) flag triggering the production
of a graph whose points are joined instead of a scatter plot.
- ``alpha`` -- number (default: not used) opacity value of the points
(or lines) in the produced graph.
- ``size`` -- integer (default: not used) size of the points (or lines)
in the produced graph.
Other named arguments affecting the graphic style are forwarded to
matplotlib's ``plot`` or ``scatter``.
OUTPUT:
figure containing a list plot.
EXAMPLES:
The following instructions generate and show a figure showing three
points:
::
>>> points = ((1, 1), (3, -1), (7, 2))
>>> from yaplf.graph import SagePlotter
>>> SagePlotter.list_plot(points)
The same graph can be obtained joining the single points:
::
>>> SagePlotter.list_plot(points, joined = True)
When ``joined`` is set to ``True``, the ``size``, ``color``, and
``alpha`` arguments affect respectively the line size, color, and
opacity:
::
>>> SagePlotter.list_plot(points, joined = True, size = 3,
... alpha = .2)
When the first argument of ``list_plot`` is a list or tuple of
three-sized list or tuples, the result is a 3D graph:
::
>>> points = ((1, 3, -4), (2, 1, 2), (1, 6, 5))
>>> SagePlotter.list_plot(points)
AUTHORS:
- Dario Malchiodi (2010-02-22)
"""
try:
joined = kwargs['joined']
del kwargs['joined']
except KeyError:
joined = False
if len(shape(points)) == 1:
points = zip(range(len(points)), points)
if len(points[0]) == 2:
try:
size = kwargs['size']
del kwargs['size']
if joined:
kwargs['thickness'] = size
else:
kwargs['pointsize'] = size
except KeyError:
pass
elif len(points[0]) == 3:
try:
alpha = kwargs['alpha']
del kwargs['alpha']
kwargs['opacity'] = alpha
if joined:
size = kwargs['size']
del kwargs['size']
kwargs['thickness'] = size
except KeyError:
pass
else:
raise ValueError('scatter() only available for 2D and 3D points')
if joined:
#.........这里部分代码省略.........
开发者ID:dariomalchiodi,项目名称:yaplf,代码行数:101,代码来源:__init__.py
示例14: plot
#.........这里部分代码省略.........
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()
sage: F = S2.diff_mapping(R3, {(XS, X3): [sin(th)*cos(ph),
....: sin(th)*sin(ph), cos(th)]}, name='F')
sage: F.display()
F: S^2 --> R^3
on U: (th, ph) |--> (x, y, z) = (cos(ph)*sin(th), sin(ph)*sin(th), cos(th))
sage: c = S2.curve([2*atan(exp(-t/10)), t], (t, -oo, +oo), name='c')
sage: graph_c = c.plot(mapping=F, max_value=40,
....: plot_points=200, thickness=2, label_axes=False) # 3D plot
sage: graph_S2 = XS.plot(X3, mapping=F, nb_values=11, color='black') # plot of the sphere
sage: show(graph_c + graph_S2) # the loxodrome + the sphere
Example of use of the argument ``parameters``: we define a curve with
some symbolic parameters ``a`` and ``b``::
sage: a, b = var('a b')
sage: c = R2.curve([a*cos(t) + b, a*sin(t)], (t, 0, 2*pi), name='c')
To make a plot, we set spectific values for ``a`` and ``b`` by means
of the Python dictionary ``parameters``::
sage: c.plot(parameters={a: 2, b: -3}, aspect_ratio=1)
Graphics object consisting of 1 graphics primitive
"""
from sage.rings.infinity import Infinity
from sage.misc.functional import numerical_approx
from sage.plot.graphics import Graphics
from sage.plot.line import line
from sage.geometry.manifolds.chart import Chart
from sage.geometry.manifolds.utilities import set_axes_labels
#
# The "effective" curve to be plotted
#
if mapping is None:
eff_curve = self
else:
eff_curve = mapping.restrict(self.codomain()) * self
#
# The chart w.r.t. which the curve is plotted
#
if chart is None:
chart = eff_curve._codomain.default_chart()
elif not isinstance(chart, Chart):
raise TypeError("{} is not a chart".format(chart))
#
# Coordinates of the above chart w.r.t. which the curve is plotted
#
if ambient_coords is None:
ambient_coords = chart[:] # all chart coordinates are used
n_pc = len(ambient_coords)
if n_pc != 2 and n_pc !=3:
raise ValueError("The number of coordinates involved in the " +
"plot must be either 2 or 3, not {}".format(n_pc))
ind_pc = [chart[:].index(pc) for pc in ambient_coords] # indices of plot
# coordinates
#
# Parameter range for the plot
#
if prange is None:
prange = (self._domain.lower_bound(), self._domain.upper_bound())
开发者ID:gaby7646,项目名称:sage,代码行数:67,代码来源:curve.py
示例15: show
def show(self, **args):
r"""
Displays the pseudoline arrangement as a wiring diagram.
INPUT:
- ``**args`` -- any arguments to be forwarded to the ``show`` method. In
particular, to tune the dimensions, use the ``figsize`` argument
(example below).
EXAMPLES::
sage: from sage.geometry.pseudolines import PseudolineArrangement
sage: permutations = [[3, 2, 1], [3, 2, 0], [3, 1, 0], [2, 1, 0]]
sage: p = PseudolineArrangement(permutations)
sage: p.show(figsize=[7,5])
TESTS::
sage: from sage.geometry.pseudolines import PseudolineArrangement
sage: permutations = [[3, 2, 1], [3, 2, 0], [3, 0, 1], [2, 0, 1]]
sage: p = PseudolineArrangement(permutations)
sage: p.show()
Traceback (most recent call last):
...
ValueError: There has been a problem while plotting the figure...
"""
x = 1
from sage.plot.line import line
from sage.plot.text import text
lines = [[(0,self._n-1-i)] for i in range(self._n)]
for i,j in self.transpositions():
iy = lines[i][-1][1]
jy = lines[j][-1][1]
lines[i].append((x, iy))
lines[j].append((x, jy))
if abs(iy-jy) != 1:
raise ValueError(
"There has been a problem while plotting the figure. It "+
"seems that the lines are not correctly ordered. Please "+
"check the pseudolines modules documentation, there is a "
+"warning about that. ")
lines[i].append((x+2,jy))
lines[j].append((x+2,iy))
x += 2
L = line([(1,1)])
for i, l in enumerate(lines):
l.append((x+2, l[-1][1]))
L += line(l)
L += text(str(i), (0, l[0][1]+.3), horizontal_alignment="right")
L += text(str(i), (x+2, l[-1][1]+.3), horizontal_alignment="left")
return L.show(axes = False, **args)
开发者ID:sagemath,项目名称:sage,代码行数:62,代码来源:pseudolines.py
示例16: plot
#.........这里部分代码省略.........
A = \begin{pmatrix} 0&0&1\\ 0&1&0\\ 1&0&0\\ \end{pmatrix}
gives:
.. PLOT::
:width: 200 px
A = AlternatingSignMatrix([[0, 0, 1], [0, 1, 0], [1, 0, 0]])
fpl = FullyPackedLoop(A)
p = fpl.plot()
sphinx_plot(p)
EXAMPLES::
sage: A = AlternatingSignMatrix([[0, 1, 0, 0], [1, -1, 0, 1], \
[0, 1, 0, 0],[0, 0, 1, 0]])
sage: fpl = FullyPackedLoop(A)
sage: print(fpl.plot().description())
Line defined by 2 points: [(-1.0, 0.0), (0.0, 0.0)]
Line defined by 2 points: [(-1.0, 2.0), (0.0, 2.0)]
Line defined by 2 points: [(0.0, 1.0), (0.0, 0.0)]
Line defined by 2 points: [(0.0, 1.0), (1.0, 1.0)]
Line defined by 2 points: [(0.0, 3.0), (0.0, 4.0)]
Line defined by 2 points: [(0.0, 3.0), (0.0, 4.0)]
Line defined by 2 points: [(0.0, 3.0), (1.0, 3.0)]
Line defined by 2 points: [(1.0, 0.0), (1.0, -1.0)]
Line defined by 2 points: [(1.0, 0.0), (2.0, 0.0)]
Line defined by 2 points: [(1.0, 2.0), (0.0, 2.0)]
Line defined by 2 points: [(1.0, 2.0), (2.0, 2.0)]
Line defined by 2 points: [(2.0, 1.0), (1.0, 1.0)]
Line defined by 2 points: [(2.0, 1.0), (2.0, 2.0)]
Line defined by 2 points: [(2.0, 3.0), (1.0, 3.0)]
Line defined by 2 points: [(2.0, 3.0), (2.0, 4.0)]
Line defined by 2 points: [(2.0, 3.0), (2.0, 4.0)]
Line defined by 2 points: [(3.0, 0.0), (2.0, 0.0)]
Line defined by 2 points: [(3.0, 0.0), (3.0, -1.0)]
Line defined by 2 points: [(3.0, 2.0), (3.0, 1.0)]
Line defined by 2 points: [(3.0, 2.0), (3.0, 3.0)]
Line defined by 2 points: [(4.0, 1.0), (3.0, 1.0)]
Line defined by 2 points: [(4.0, 1.0), (3.0, 1.0)]
Line defined by 2 points: [(4.0, 3.0), (3.0, 3.0)]
Line defined by 2 points: [(4.0, 3.0), (3.0, 3.0)]
Here is the plot:
.. PLOT::
:width: 300 px
A = AlternatingSignMatrix([[0, 1, 0, 0], [1, -1, 0, 1], [0, 1, 0, 0],[0, 0, 1, 0]])
fpl = FullyPackedLoop(A)
p = fpl.plot()
sphinx_plot(p)
"""
G = Graphics()
n=len(self._six_vertex_model)-1
for j,row in enumerate(reversed(self._six_vertex_model)):
for i,entry in enumerate(row):
if i == 0 and (i+j+n+1) % 2 ==0:
G+= line([(i-1,j),(i,j)])
if i == n and (i+j+n+1) % 2 ==0:
G+= line([(i+1,j),(i,j)])
if j == 0 and (i+j+n) % 2 ==0:
G+= line([(i,j),(i,j-1)])
if j == n and (i+j+n) % 2 ==0:
G+= line([(i,j),(i,j+1)])
if entry == 0: # LR
if (i+j+n) % 2==0:
G += line([(i,j), (i+1,j)])
else:
G += line([(i,j),(i,j+1)])
elif entry == 1: # LU
if (i+j+n) % 2 ==0:
G += line([(i,j), (i,j+1)])
else:
G += line([(i+1,j), (i,j)])
elif entry == 2: # LD
if (i+j+n) % 2 == 0:
pass
else:
G += line([(i,j+1), (i,j)])
G += line([(i+1,j), (i,j)])
elif entry == 3: # UD
if (i+j+n) % 2 == 0:
G += line([(i,j), (i,j+1)])
else:
G += line([(i+1,j), (i,j)])
elif entry == 4: # UR
if (i+j+n) % 2 ==0:
G += line([(i,j), (i,j+1)])
G += line([(i,j), (i+1,j)])
else:
pass
elif entry == 5: # RD
if (i+j+n) % 2 ==0:
G += line([(i,j), (i+1,j)])
else:
G += line([(i,j+1), (i,j)])
G.axes(False)
return G
开发者ID:mcognetta,项目名称:sage,代码行数:101,代码来源:fully_packed_loop.py
示例17: _graphics
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
开发者ID:saraedum,项目名称:sage-renamed,代码行数:68,代码来源:curve.py
示例18: plot
def plot(self, size=[[0],[0]], projection='usual', simple_roots=True, fundamental_weights=True, alcovewalks=[]):
r"""
Return a graphics object built from a space of weight(space/lattice).
There is a different technic to plot if the Cartan type is affine or not.
The graphics returned is a Graphics object.
This function is experimental, and is subject to short term evolutions.
EXAMPLES::
By default, the plot returned has no axes and the ratio between axes is 1.
sage: G = RootSystem(['C',2]).weight_lattice().plot()
sage: G.axes(True)
sage: G.set_aspect_ratio(2)
For a non affine Cartan type, the plot method work for type with 2 generators,
it will draw the hyperlane(line for this dimension) accrow the fundamentals weights.
sage: G = RootSystem(['A',2]).weight_lattice().plot()
sage: G = RootSystem(['B',2]).weight_lattice().plot()
sage: G = RootSystem(['G',2]).weight_lattice().plot()
The plot returned has a size of one fundamental polygon by default. We can
ask plot to give a bigger plot by using the argument size
sage: G = RootSystem(['G',2,1]).weight_space().plot(size = [[0..1],[-1..1]])
sage: G = RootSystem(['A',2,1]).weight_space().plot(size = [[-1..1],[-1..1]])
A very important argument is the projection which will draw the plot. There are
some usual projections is this method. If you want to draw in the plane a very
special Cartan type, Sage will ask you to specify the projection. The projection
is a matrix over a ring. In practice, calcul over float is a good way to draw.
sage: L = RootSystem(['A',2,1]).weight_space()
sage: G = L.plot(projection=matrix(RR, [[0,0.5,-0.5],[0,0.866,0.866]]))
sage: G = RootSystem(['C',2,1]).weight_space().plot()
By default, the plot method draw the simple roots, this can be disabled by setting
the argument simple_roots=False
sage: G = RootSystem(['A',2]).weight_space().plot(simple_roots=False)
By default, the plot method draw the fundamental weights,this can be disabled by
setting the argument fundamental_weights=False
sage: G = RootSystem(['A',2]).weight_space().plot(fundamental_weights=False, simple_roots=False)
There is in a plot an argument to draw alcoves walks. The good way to do this is
to use the crystals theory. the plot method contains only the drawing part...
sage: L = RootSystem(['A',2,1]).weight_space()
sage: G = L.plot(size=[[-1..1],[-1..1]],alcovewalks=[[0,2,0,1,2,1,2,0,2,1]])
"""
from sage.plot.all import Graphics
from sage.plot.line import line
from cartan_type import CartanType
from sage.matrix.constructor import matrix
from sage.rings.all import QQ, RR
from sage.plot.arrow import arrow
from sage.plot.point import point
# We begin with an empty plot G
G = Graphics()
ct = self.cartan_type()
n = ct.n
# Define a set of colors
# TODO : Colors in option ?
colors=[(0,1,0),(1,0,0),(0,0,1),(1,1,0),(0,1,1),(1,0,1)]
# plot the affine types:
if ct.is_affine():
# Check the projection
# TODO : try to have usual_projection for main plotable types
if projection == 'usual':
if ct == CartanType(['A',2,1]):
projection = matrix(RR, [[0,0.5,-0.5],[0,0.866,0.866]])
elif ct == CartanType(['C',2,1]):
projection = matrix(QQ, [[0,1,1],[0,0,1]])
elif ct == CartanType(['G',2,1]):
projection = matrix(RR, [[0,0.5,0],[0,0.866,1.732]])
else:
raise 'There is no usual projection for this Cartan type, you have to give one in argument'
assert(n + 1 == projection.ncols())
assert(2 == projection.nrows())
# Check the size is correct with the lattice
assert(len(size) == n)
# Select the center of the translated fundamental polygon to plot
translation_factors = ct.translation_factors()
simple_roots = self.simple_roots()
translation_vectors = [translation_factors[i]*simple_roots[i] for i in ct.classical().index_set()]
initial = [[]]
for i in range(n):
prod_list = []
for elem in size[i]:
for partial_list in initial:
prod_list.append( [elem]+partial_list );
i
|
请发表评论