Пример #1
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])
Пример #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])