本文整理汇总了Python中sage.plot.graphics.Graphics.axes方法的典型用法代码示例。如果您正苦于以下问题:Python Graphics.axes方法的具体用法?Python Graphics.axes怎么用?Python Graphics.axes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sage.plot.graphics.Graphics
的用法示例。
在下文中一共展示了Graphics.axes方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: plot_n_matrices_eigenvectors
# 需要导入模块: from sage.plot.graphics import Graphics [as 别名]
# 或者: from sage.plot.graphics.Graphics import axes [as 别名]
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
示例2: plot
# 需要导入模块: from sage.plot.graphics import Graphics [as 别名]
# 或者: from sage.plot.graphics.Graphics import axes [as 别名]
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
示例3: plot
# 需要导入模块: from sage.plot.graphics import Graphics [as 别名]
# 或者: from sage.plot.graphics.Graphics import axes [as 别名]
def plot(self, color='sign'):
"""
Return a plot of ``self``.
INPUT:
- ``color`` -- can be any of the following:
* ``4`` - use 4 colors: black, red, blue, and green with each
corresponding to up, right, down, and left respectively
* ``2`` - use 2 colors: red for horizontal, blue for vertical arrows
* ``'sign'`` - use red for right and down arrows, blue for left
and up arrows
* a list of 4 colors for each direction
* a function which takes a direction and a boolean corresponding
to the sign
EXAMPLES::
sage: M = SixVertexModel(2, boundary_conditions='ice')
sage: print(M[0].plot().description())
Arrow from (-1.0,0.0) to (0.0,0.0)
Arrow from (-1.0,1.0) to (0.0,1.0)
Arrow from (0.0,0.0) to (0.0,-1.0)
Arrow from (0.0,0.0) to (1.0,0.0)
Arrow from (0.0,1.0) to (0.0,0.0)
Arrow from (0.0,1.0) to (0.0,2.0)
Arrow from (1.0,0.0) to (1.0,-1.0)
Arrow from (1.0,0.0) to (1.0,1.0)
Arrow from (1.0,1.0) to (0.0,1.0)
Arrow from (1.0,1.0) to (1.0,2.0)
Arrow from (2.0,0.0) to (1.0,0.0)
Arrow from (2.0,1.0) to (1.0,1.0)
"""
from sage.plot.graphics import Graphics
from sage.plot.circle import circle
from sage.plot.arrow import arrow
if color == 4:
color_list = ['black', 'red', 'blue', 'green']
cfunc = lambda d,pm: color_list[d]
elif color == 2:
cfunc = lambda d,pm: 'red' if d % 2 == 0 else 'blue'
elif color == 1 or color is None:
cfunc = lambda d,pm: 'black'
elif color == 'sign':
cfunc = lambda d,pm: 'red' if pm else 'blue' # RD are True
elif isinstance(color, (list, tuple)):
cfunc = lambda d,pm: color[d]
else:
cfunc = color
G = Graphics()
for j,row in enumerate(reversed(self)):
for i,entry in enumerate(row):
if entry == 0: # LR
G += arrow((i,j+1), (i,j), color=cfunc(2, True))
G += arrow((i,j), (i+1,j), color=cfunc(1, True))
if j == 0:
G += arrow((i,j-1), (i,j), color=cfunc(0, False))
if i == 0:
G += arrow((i,j), (i-1,j), color=cfunc(3, False))
elif entry == 1: # LU
G += arrow((i,j), (i,j+1), color=cfunc(0, False))
G += arrow((i+1,j), (i,j), color=cfunc(3, False))
if j == 0:
G += arrow((i,j-1), (i,j), color=cfunc(0, False))
if i == 0:
G += arrow((i,j), (i-1,j), color=cfunc(3, False))
elif entry == 2: # LD
G += arrow((i,j+1), (i,j), color=cfunc(2, True))
G += arrow((i+1,j), (i,j), color=cfunc(3, False))
if j == 0:
G += arrow((i,j), (i,j-1), color=cfunc(2, True))
if i == 0:
G += arrow((i,j), (i-1,j), color=cfunc(3, False))
elif entry == 3: # UD
G += arrow((i,j), (i,j+1), color=cfunc(0, False))
G += arrow((i+1,j), (i,j), color=cfunc(3, False))
if j == 0:
G += arrow((i,j), (i,j-1), color=cfunc(2, True))
if i == 0:
G += arrow((i-1,j), (i,j), color=cfunc(1, True))
elif entry == 4: # UR
G += arrow((i,j), (i,j+1), color=cfunc(0, False))
G += arrow((i,j), (i+1,j), color=cfunc(1, True))
if j == 0:
G += arrow((i,j-1), (i,j), color=cfunc(0, False))
if i == 0:
G += arrow((i-1,j), (i,j), color=cfunc(1, True))
elif entry == 5: # RD
G += arrow((i,j+1), (i,j), color=cfunc(2, True))
G += arrow((i,j), (i+1,j), color=cfunc(1, True))
if j == 0:
G += arrow((i,j), (i,j-1), color=cfunc(2, True))
if i == 0:
G += arrow((i-1,j), (i,j), color=cfunc(1, True))
G.axes(False)
return G
示例4: plot
# 需要导入模块: from sage.plot.graphics import Graphics [as 别名]
# 或者: from sage.plot.graphics.Graphics import axes [as 别名]
#.........这里部分代码省略.........
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
示例5: finalize
# 需要导入模块: from sage.plot.graphics import Graphics [as 别名]
# 或者: from sage.plot.graphics.Graphics import axes [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
示例6: plot
# 需要导入模块: from sage.plot.graphics import Graphics [as 别名]
# 或者: from sage.plot.graphics.Graphics import axes [as 别名]
def plot(self, **kwds):
r"""
Plot the initial triangulation associated to ``self``.
INPUT:
- ``radius`` - the radius of the disk; by default the length of
the circle is the number of vertices
- ``points_color`` - the color of the vertices; default 'black'
- ``points_size`` - the size of the vertices; default 7
- ``triangulation_color`` - the color of the arcs; default 'black'
- ``triangulation_thickness`` - the thickness of the arcs; default 0.5
- ``shading_color`` - the color of the shading used on neuter
intervals; default 'lightgray'
- ``reflections_color`` - the color of the reflection axes; default
'blue'
- ``reflections_thickness`` - the thickness of the reflection axes;
default 1
EXAMPLES::
sage: Y = SineGordonYsystem('A',(6,4,3))
sage: Y.plot() # long time 2s
Graphics object consisting of 219 graphics primitives
"""
# Set up plotting options
if 'radius' in kwds:
radius = kwds['radius']
else:
radius = ceil(self.r() / (2 * pi))
points_opts = {}
if 'points_color' in kwds:
points_opts['color'] = kwds['points_color']
else:
points_opts['color'] = 'black'
if 'points_size' in kwds:
points_opts['size'] = kwds['points_size']
else:
points_opts['size'] = 7
triangulation_opts = {}
if 'triangulation_color' in kwds:
triangulation_opts['color'] = kwds['triangulation_color']
else:
triangulation_opts['color'] = 'black'
if 'triangulation_thickness' in kwds:
triangulation_opts['thickness'] = kwds['triangulation_thickness']
else:
triangulation_opts['thickness'] = 0.5
shading_opts = {}
if 'shading_color' in kwds:
shading_opts['color'] = kwds['shading_color']
else:
shading_opts['color'] = 'lightgray'
reflections_opts = {}
if 'reflections_color' in kwds:
reflections_opts['color'] = kwds['reflections_color']
else:
reflections_opts['color'] = 'blue'
if 'reflections_thickness' in kwds:
reflections_opts['thickness'] = kwds['reflections_thickness']
else:
reflections_opts['thickness'] = 1
# Helper functions
def triangle(x):
(a, b) = sorted(x[:2])
for p in self.vertices():
if (p, a) in self.triangulation() or (a, p) in self.triangulation():
if (p, b) in self.triangulation() or (b, p) in self.triangulation():
if p < a or p > b:
return sorted((a, b, p))
def plot_arc(radius, p, q, **opts):
# TODO: THIS SHOULD USE THE EXISTING PLOT OF ARCS!
# plot the arc from p to q differently depending on the type of self
p = ZZ(p)
q = ZZ(q)
t = var('t')
if p - q in [1, -1]:
def f(t):
return (radius * cos(t), radius * sin(t))
(p, q) = sorted([p, q])
angle_p = vertex_to_angle(p)
angle_q = vertex_to_angle(q)
return parametric_plot(f(t), (t, angle_q, angle_p), **opts)
if self.type() == 'A':
angle_p = vertex_to_angle(p)
angle_q = vertex_to_angle(q)
if angle_p < angle_q:
angle_p += 2 * pi
internal_angle = angle_p - angle_q
if internal_angle > pi:
(angle_p, angle_q) = (angle_q + 2 * pi, angle_p)
internal_angle = angle_p - angle_q
angle_center = (angle_p+angle_q) / 2
hypotenuse = radius / cos(internal_angle / 2)
radius_arc = hypotenuse * sin(internal_angle / 2)
center = (hypotenuse * cos(angle_center),
hypotenuse * sin(angle_center))
center_angle_p = angle_p + pi / 2
#.........这里部分代码省略.........
示例7: plot
# 需要导入模块: from sage.plot.graphics import Graphics [as 别名]
# 或者: from sage.plot.graphics.Graphics import axes [as 别名]
#.........这里部分代码省略.........
while cyclic_order[j][2][1]==1:
j-=1
a=A0.inverse_letter(cyclic_order[j][2][0])
x=boundary_initial_vertex[a][0]
y=boundary_initial_vertex[a][1]
g+=line([(x,y),(xx,yy)],alpha=1,thickness=2,hue=RR(A1.rank(b))/N)
g+=text(e[2][0],(text_decalage*xx,text_decalage*yy),hue=RR(A1.rank(b))/N)
for e in self.isolated_edges():
if e[2][1]==1:
#The end of e is at the singularity
b=e[2][0]
i=0
j=0
while cyclic_order[i][2][1]==0 or cyclic_order[i][2][0]!=b:
if cyclic_order[i][2][1]==0:
j=i
i+=1
if j==0 and cyclic_order[j][2][1]==1:
j=len(cyclic_order)-1
while cyclic_order[j][2][1]==1:
j-=1
a=A0.inverse_letter(cyclic_order[j][2][0])
x=boundary_initial_vertex[a][0]
y=boundary_initial_vertex[a][1]
#The start of e is also at the singularity
bb=A1.inverse_letter(b)
i=0
j=0
while cyclic_order[i][2][1]==0 or cyclic_order[i][2][0]!=bb:
if cyclic_order[i][2][1]==0:
j=i
i+=1
if j==0 and cyclic_order[j][2][1]==1:
j=len(cyclic_order)-1
while cyclic_order[j][2][1]==1:
j-=1
aa=A0.inverse_letter(cyclic_order[j][2][0])
xx=boundary_initial_vertex[aa][0]
yy=boundary_initial_vertex[aa][1]
g+=line([(x,y),(xx,yy)],alpha=1,thickness=2,hue=RR(A1.rank(b))/N)
g+=text(b,(text_decalage*x,text_decalage*y),hue=RR(A1.rank(b))/N)
for sq in self.twice_light_squares():
b=A1.to_positive_letter(sq[5])
#The end of b is at the singularity
i=0
j=0
while cyclic_order[i][2][1]==0 or cyclic_order[i][2][0]!=b:
if cyclic_order[i][2][1]==0:
j=i
i+=1
if j==0 and cyclic_order[j][2][1]==1:
j=len(cyclic_order)-1
while cyclic_order[j][2][1]==1:
j-=1
a=A0.inverse_letter(cyclic_order[j][2][0])
x=boundary_initial_vertex[a][0]
y=boundary_initial_vertex[a][1]
#The start of b is also at the singularity
bb=A1.inverse_letter(b)
i=0
j=0
while cyclic_order[i][2][1]==0 or cyclic_order[i][2][0]!=bb:
if cyclic_order[i][2][1]==0:
j=i
i+=1
if j==0 and cyclic_order[j][2][1]==1:
j=len(cyclic_order)-1
while cyclic_order[j][2][1]==1:
j-=1
aa=A0.inverse_letter(cyclic_order[j][2][0])
xx=boundary_initial_vertex[aa][0]
yy=boundary_initial_vertex[aa][1]
g+=line([(x,y),(xx,yy)],alpha=1,thickness=2,hue=RR(A1.rank(b))/N)
g+=text(b,(text_decalage*x,text_decalage*y),hue=RR(A1.rank(b))/N)
g.axes(False)
return g