本文整理汇总了Python中sage.plot.graphics.Graphics._extract_kwds_for_show方法的典型用法代码示例。如果您正苦于以下问题:Python Graphics._extract_kwds_for_show方法的具体用法?Python Graphics._extract_kwds_for_show怎么用?Python Graphics._extract_kwds_for_show使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sage.plot.graphics.Graphics
的用法示例。
在下文中一共展示了Graphics._extract_kwds_for_show方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: bar_chart
# 需要导入模块: from sage.plot.graphics import Graphics [as 别名]
# 或者: from sage.plot.graphics.Graphics import _extract_kwds_for_show [as 别名]
def bar_chart(datalist, **options):
"""
A bar chart of (currently) one list of numerical data.
Support for more data lists in progress.
EXAMPLES:
A bar_chart with blue bars::
sage: bar_chart([1,2,3,4])
Graphics object consisting of 1 graphics primitive
A bar_chart with thinner bars::
sage: bar_chart([x^2 for x in range(1,20)], width=0.2)
Graphics object consisting of 1 graphics primitive
A bar_chart with negative values and red bars::
sage: bar_chart([-3,5,-6,11], rgbcolor=(1,0,0))
Graphics object consisting of 1 graphics primitive
A bar chart with a legend (it's possible, not necessarily useful)::
sage: bar_chart([-1,1,-1,1], legend_label='wave')
Graphics object consisting of 1 graphics primitive
Extra options will get passed on to show(), as long as they are valid::
sage: bar_chart([-2,8,-7,3], rgbcolor=(1,0,0), axes=False)
Graphics object consisting of 1 graphics primitive
sage: bar_chart([-2,8,-7,3], rgbcolor=(1,0,0)).show(axes=False) # These are equivalent
"""
dl = len(datalist)
#if dl > 1:
# print "WARNING, currently only 1 data set allowed"
# datalist = datalist[0]
if dl == 3:
datalist = datalist+[0]
#bardata = []
#cnt = 1
#for pnts in datalist:
#ind = [i+cnt/dl for i in range(len(pnts))]
#bardata.append([ind, pnts, xrange, yrange])
#cnt += 1
g = Graphics()
g._set_extra_kwds(Graphics._extract_kwds_for_show(options))
#TODO: improve below for multiple data sets!
#cnt = 1
#for ind, pnts, xrange, yrange in bardata:
#options={'rgbcolor':hue(cnt/dl),'width':0.5/dl}
# g._bar_chart(ind, pnts, xrange, yrange, options=options)
# cnt += 1
#else:
ind = list(range(len(datalist)))
g.add_primitive(BarChart(ind, datalist, options=options))
if options['legend_label']:
g.legend(True)
return g
示例2: arc
# 需要导入模块: from sage.plot.graphics import Graphics [as 别名]
# 或者: from sage.plot.graphics.Graphics import _extract_kwds_for_show [as 别名]
def arc(center, r1, r2=None, angle=0.0, sector=(0.0, 2 * pi), **options):
r"""
An arc (that is a portion of a circle or an ellipse)
Type ``arc.options`` to see all options.
INPUT:
- ``center`` - 2-tuple of real numbers - position of the center.
- ``r1``, ``r2`` - positive real numbers - radii of the ellipse. If only ``r1``
is set, then the two radii are supposed to be equal and this function returns
an arc of of circle.
- ``angle`` - real number - angle between the horizontal and the axis that
corresponds to ``r1``.
- ``sector`` - 2-tuple (default: (0,2*pi))- angles sector in which the arc will
be drawn.
OPTIONS:
- ``alpha`` - float (default: 1) - transparency
- ``thickness`` - float (default: 1) - thickness of the arc
- ``color``, ``rgbcolor`` - string or 2-tuple (default: 'blue') - the color
of the arc
- ``linestyle`` - string (default: ``'solid'``) - The style of the line,
which is one of ``'dashed'``, ``'dotted'``, ``'solid'``, ``'dashdot'``,
or ``'--'``, ``':'``, ``'-'``, ``'-.'``, respectively.
EXAMPLES:
Plot an arc of circle centered at (0,0) with radius 1 in the sector
`(\pi/4,3*\pi/4)`::
sage: arc((0,0), 1, sector=(pi/4,3*pi/4))
Graphics object consisting of 1 graphics primitive
Plot an arc of an ellipse between the angles 0 and `\pi/2`::
sage: arc((2,3), 2, 1, sector=(0,pi/2))
Graphics object consisting of 1 graphics primitive
Plot an arc of a rotated ellipse between the angles 0 and `\pi/2`::
sage: arc((2,3), 2, 1, angle=pi/5, sector=(0,pi/2))
Graphics object consisting of 1 graphics primitive
Plot an arc of an ellipse in red with a dashed linestyle::
sage: arc((0,0), 2, 1, 0, (0,pi/2), linestyle="dashed", color="red")
Graphics object consisting of 1 graphics primitive
sage: arc((0,0), 2, 1, 0, (0,pi/2), linestyle="--", color="red")
Graphics object consisting of 1 graphics primitive
The default aspect ratio for arcs is 1.0::
sage: arc((0,0), 1, sector=(pi/4,3*pi/4)).aspect_ratio()
1.0
It is not possible to draw arcs in 3D::
sage: A = arc((0,0,0), 1)
Traceback (most recent call last):
...
NotImplementedError
"""
from sage.plot.all import Graphics
# Reset aspect_ratio to 'automatic' in case scale is 'semilog[xy]'.
# Otherwise matplotlib complains.
scale = options.get('scale', None)
if isinstance(scale, (list, tuple)):
scale = scale[0]
if scale == 'semilogy' or scale == 'semilogx':
options['aspect_ratio'] = 'automatic'
if len(center) == 2:
if r2 is None:
r2 = r1
g = Graphics()
g._set_extra_kwds(Graphics._extract_kwds_for_show(options))
if len(sector) != 2:
raise ValueError("the sector must consist of two angles")
g.add_primitive(Arc(
center[0], center[1],
r1, r2,
angle,
sector[0], sector[1],
options))
return g
elif len(center) == 3:
raise NotImplementedError