本文整理汇总了Python中matplotlib.backend_bases.GraphicsContextBase类的典型用法代码示例。如果您正苦于以下问题:Python GraphicsContextBase类的具体用法?Python GraphicsContextBase怎么用?Python GraphicsContextBase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GraphicsContextBase类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: set_linewidth
def set_linewidth(self, w):
GraphicsContextBase.set_linewidth(self, w)
if w == 0:
self.gdkGC.line_width = 0
else:
pixels = self.renderer.points_to_pixels(w)
self.gdkGC.line_width = max(1, int(round(pixels)))
开发者ID:08s011003,项目名称:nupic,代码行数:7,代码来源:backend_gdk.py
示例2: set_clip_rectangle
def set_clip_rectangle(self, rectangle):
GraphicsContextBase.set_clip_rectangle(self, rectangle)
l, b, w, h = rectangle
rectangle = (int(l), self.renderer.height - int(b + h) + 1, int(w), int(h))
# rectangle = (int(l), self.renderer.height-int(b+h),
# int(w+1), int(h+2))
self.gdkGC.set_clip_rectangle(rectangle)
开发者ID:,项目名称:,代码行数:7,代码来源:
示例3: __init__
def __init__(self, im, renderer):
"""
Initialize with a gd image
"""
GraphicsContextBase.__init__(self)
self.im = im
self.renderer = renderer
开发者ID:,项目名称:,代码行数:7,代码来源:
示例4: set_foreground
def set_foreground(self, fg, isRGB=None):
"""
Set the foreground color. fg can be a matlab format string, a
html hex color string, an rgb unit tuple, or a float between 0
and 1. In the latter case, grayscale is used.
"""
GraphicsContextBase.set_foreground(self, fg, isRGB)
self.ctx.set_rgb_color(*self._rgb)
开发者ID:,项目名称:,代码行数:8,代码来源:
示例5: set_dashes
def set_dashes(self, dash_offset, dash_list):
GraphicsContextBase.set_dashes(self, dash_offset, dash_list)
# dash_list is a list with numbers denoting the number of points
# in a dash and if it is on or off.
if dash_list is not None:
self.line['dash_list'] = dash_list
if dash_offset is not None:
self.line['dash_offset'] = int(dash_offset)
开发者ID:kivy-garden,项目名称:garden.matplotlib,代码行数:8,代码来源:backend_kivy.py
示例6: set_linestyle
def set_linestyle(self, style):
"""
Set the linestyle to be one of ('solid', 'dashed', 'dashdot',
'dotted').
"""
GraphicsContextBase.set_linestyle(self, style)
offset, dashes = self._dashd[style]
self.set_dashes(offset, dashes)
开发者ID:,项目名称:,代码行数:8,代码来源:
示例7: set_alpha
def set_alpha(self, alpha):
GraphicsContextBase.set_alpha(self, alpha)
_alpha = self.get_alpha()
rgb = self._rgb
if self.get_forced_alpha():
self.ctx.set_source_rgba(rgb[0], rgb[1], rgb[2], _alpha)
else:
self.ctx.set_source_rgba(rgb[0], rgb[1], rgb[2], rgb[3])
开发者ID:tomflannaghan,项目名称:matplotlib,代码行数:8,代码来源:backend_cairo.py
示例8: set_dashes
def set_dashes(self, dash_offset, dash_list):
GraphicsContextBase.set_dashes(self, dash_offset, dash_list)
if dash_list == None:
self.gdkGC.line_style = gdk.LINE_SOLID
else:
pixels = self.renderer.points_to_pixels(npy.asarray(dash_list))
dl = [max(1, int(round(val))) for val in pixels]
self.gdkGC.set_dashes(dash_offset, dl)
self.gdkGC.line_style = gdk.LINE_ON_OFF_DASH
开发者ID:,项目名称:,代码行数:9,代码来源:
示例9: set_joinstyle
def set_joinstyle(self, js):
"""
Set the join style to be one of ('miter', 'round', 'bevel')
"""
DEBUG_MSG("set_joinstyle()", 1, self)
self.select()
GraphicsContextBase.set_joinstyle(self, js)
self._pen.SetJoin(GraphicsContextWx._joind[self._joinstyle])
self.gfx_ctx.SetPen(self._pen)
self.unselect()
开发者ID:,项目名称:,代码行数:10,代码来源:
示例10: set_capstyle
def set_capstyle(self, cs):
"""
Set the capstyle as a string in ('butt', 'round', 'projecting')
"""
DEBUG_MSG("set_capstyle()", 1, self)
self.select()
GraphicsContextBase.set_capstyle(self, cs)
self._pen.SetCap(GraphicsContextWx._capd[self._capstyle])
self.gfx_ctx.SetPen(self._pen)
self.unselect()
开发者ID:,项目名称:,代码行数:10,代码来源:
示例11: set_graylevel
def set_graylevel(self, frac):
"""
Set the foreground color. fg can be a matlab format string, a
html hex color string, an rgb unit tuple, or a float between 0
and 1. In the latter case, grayscale is used.
"""
DEBUG_MSG("set_graylevel()", 1, self)
self.select()
GraphicsContextBase.set_graylevel(self, frac)
self._pen.SetColour(self.get_wxcolour(self.get_rgb()))
self.gfx_ctx.SetPen(self._pen)
self.unselect()
开发者ID:,项目名称:,代码行数:12,代码来源:
示例12: set_linewidth
def set_linewidth(self, w):
"""
Set the line width.
"""
DEBUG_MSG("set_linewidth()", 1, self)
self.select()
if w>0 and w<1: w = 1
GraphicsContextBase.set_linewidth(self, w)
lw = int(self.renderer.points_to_pixels(self._linewidth))
if lw==0: lw = 1
self._pen.SetWidth(lw)
self.gfx_ctx.SetPen(self._pen)
self.unselect()
开发者ID:,项目名称:,代码行数:13,代码来源:
示例13: DISABLED_memleak
def DISABLED_memleak( self ):
"""Test agg backend for memory leaks."""
fontname = '/usr/local/share/matplotlib/Vera.ttf'
fname = self.outFile( "agg_memleak_%05d.png" )
N = 200
for i in range( N ):
gc = GraphicsContextBase()
gc.set_clip_rectangle( [20, 20, 20, 20] )
o = RendererAgg( 400, 400, 72 )
for j in range( 50 ):
xs = [ 400*int(rand()) for k in range(8) ]
ys = [ 400*int(rand()) for k in range(8) ]
rgb = (1, 0, 0)
pnts = zip( xs, ys )
o.draw_polygon( gc, rgb, pnts )
o.draw_polygon( gc, None, pnts )
for j in range( 50 ):
x = [ 400*int(rand()) for k in range(4) ]
y = [ 400*int(rand()) for k in range(4) ]
o.draw_lines( gc, x, y )
for j in range( 50 ):
args = [ 400*int(rand()) for k in range(4) ]
rgb = (1, 0, 0)
o.draw_rectangle( gc, rgb, *args )
if 1: # add text
font = FT2Font( fontname )
font.clear()
font.set_text( 'hi mom', 60 )
font.set_size( 12, 72 )
o.draw_text_image( font.get_image(), 30, 40, gc )
o.write_png( fname % i )
val = report_memory( i )
if i==1: start = val
end = val
avgMem = (end - start) / float(N)
print 'Average memory consumed per loop: %1.4f\n' % (avgMem)
#TODO: Verify the expected mem usage and approximate tolerance that should be used
self.checkClose( 0.32, avgMem, absTol = 0.1 )
开发者ID:,项目名称:,代码行数:48,代码来源:
示例14: set_clip_path
def set_clip_path(self, path):
GraphicsContextBase.set_clip_path(self, path)
if not path: return
path = path.get_fully_transformed_path()
for points, code in path.iter_segments():
if code == Path.MOVETO:
self.moveto(points)
elif code == Path.LINETO:
self.lineto(points)
elif code == Path.CURVE3:
self.curve3(points)
elif code == Path.CURVE4:
self.curve4(points)
elif code == Path.CLOSEPOLY:
self.closepoly()
self.clip_path()
开发者ID:,项目名称:,代码行数:16,代码来源:
示例15: write_header
def write_header(self, resolution=72):
from matplotlib.backends.backend_agg import RendererAgg, Figure
from matplotlib.backend_bases import GraphicsContextBase
try:
from matplotlib.transforms import Value
except ImportError:
dpi = resolution
else:
dpi = Value(resolution)
self.renderer = RendererAgg(self.w, self.h, dpi)
self.figure = Figure()
self.gc = GraphicsContextBase()
self.gc.set_linewidth(.2)
开发者ID:gitter-badger,项目名称:kmos,代码行数:16,代码来源:png.py
示例16: set_graylevel
def set_graylevel(self, fg):
GraphicsContextBase.set_graylevel(self, fg)
_macosx.GraphicsContext.set_graylevel(self, fg)
开发者ID:AdamHeck,项目名称:matplotlib,代码行数:3,代码来源:backend_macosx.py
示例17: set_foreground
def set_foreground(self, fg, isRGBA=False):
GraphicsContextBase.set_foreground(self, fg, isRGBA)
rgb = self.get_rgb()
_macosx.GraphicsContext.set_foreground(self, rgb)
开发者ID:AdamHeck,项目名称:matplotlib,代码行数:4,代码来源:backend_macosx.py
示例18: set_alpha
def set_alpha(self, alpha):
GraphicsContextBase.set_alpha(self, alpha)
_alpha = self.get_alpha()
_macosx.GraphicsContext.set_alpha(self, _alpha, self.get_forced_alpha())
rgb = self.get_rgb()
_macosx.GraphicsContext.set_foreground(self, rgb)
开发者ID:AdamHeck,项目名称:matplotlib,代码行数:6,代码来源:backend_macosx.py
示例19: __init__
def __init__(self):
GraphicsContextBase.__init__(self)
_macosx.GraphicsContext.__init__(self)
开发者ID:AdamHeck,项目名称:matplotlib,代码行数:3,代码来源:backend_macosx.py
示例20: set_clip_rectangle
def set_clip_rectangle(self, box):
GraphicsContextBase.set_clip_rectangle(self, box)
if not box: return
_macosx.GraphicsContext.set_clip_rectangle(self, box.bounds)
开发者ID:AdamHeck,项目名称:matplotlib,代码行数:4,代码来源:backend_macosx.py
注:本文中的matplotlib.backend_bases.GraphicsContextBase类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论