Пример #1
0
def chunk_limit_setup():
    N = 100_000
    dpi = 500
    w = 5 * dpi
    h = 6 * dpi

    # just fit in the width
    x = np.linspace(0, w, N)
    # and go top-to-bottom
    y = np.ones(N) * h
    y[::2] = 0

    idt = IdentityTransform()
    # make a renderer
    ra = RendererAgg(w, h, dpi)
    # setup the minimal gc to draw a line
    gc = ra.new_gc()
    gc.set_linewidth(1)
    gc.set_foreground('r')
    # make a Path
    p = Path(np.vstack((x, y)).T)
    # effectively disable path simplification (but leaving it "on")
    p.simplify_threshold = 0

    return ra, gc, p, idt
Пример #2
0
# working directly with renderer and graphics contexts primitives
from matplotlib.font_manager import FontProperties
from matplotlib.backends.backend_agg import RendererAgg
from matplotlib.transforms import Value

# a 400x400 canvas at 72dpi canvas
dpi = Value(72.0)
o = RendererAgg(400,400, dpi)  

# the graphics context 
gc = o.new_gc()

# draw the background white
gc.set_foreground('w')
face = (1,1,1)  # white
o.draw_rectangle(gc, face, 0, 0, 400, 400)

# the gc's know about color strings, and can handle any matplotlib
# color arguments (hex strings, rgb, format strings, etc)
gc.set_foreground('g')
gc.set_linewidth(4)
face = (1,0,0)  # must be rgb
o.draw_rectangle(gc, face, 10, 50, 100, 200)

# draw a translucent ellipse
rgb = (0,0,1)
gc.set_alpha(0.5)
o.draw_arc(gc, rgb,  100, 100, 100, 100, 360, 360, 0)

# draw a dashed line
gc.set_dashes(0, [5, 10])
Пример #3
0
# working directly with renderer and graphics contexts primitives
from matplotlib.font_manager import FontProperties
from matplotlib.backends.backend_agg import RendererAgg
from matplotlib.transforms import Value

# a 400x400 canvas at 72dpi canvas
dpi = Value(72.0)
o = RendererAgg(400, 400, dpi)

# the graphics context
gc = o.new_gc()

# draw the background white
gc.set_foreground('w')
face = (1, 1, 1)  # white
o.draw_rectangle(gc, face, 0, 0, 400, 400)

# the gc's know about color strings, and can handle any matplotlib
# color arguments (hex strings, rgb, format strings, etc)
gc.set_foreground('g')
gc.set_linewidth(4)
face = (1, 0, 0)  # must be rgb
o.draw_rectangle(gc, face, 10, 50, 100, 200)

# draw a translucent ellipse
rgb = (0, 0, 1)
gc.set_alpha(0.5)
o.draw_arc(gc, rgb, 100, 100, 100, 100, 360, 360, 0)

# draw a dashed line
gc.set_dashes(0, [5, 10])