api example code: compound_path.py — Matplotlib 2.0.2 documentation
You are reading an old version of the documentation (v2.0.2). For the latest version see https://matplotlib.org/stable/ Navigation index modules | next | previous | home | examples | gallery | pyplot | docs » Matplotlib Examples » api Examples » Travis-CI: Related Topics Documentation overview Matplotlib Examples api Examples Previous: api example code: colorbar_only.py Next: api example code: custom_projection_example.py This Page Show Source Quick search api example code: compound_path.py ¶ ( Source code , png , pdf ) """ ============= Compound path ============= Make a compound path -- in this case two simple polygons, a rectangle and a triangle.
Use CLOSEPOLY and MOVETO for the different parts of the compound path """ import numpy as np from matplotlib.path import Path from matplotlib.patches import PathPatch import matplotlib.pyplot as plt vertices = [] codes = [] codes = [ Path . MOVETO ] + [ Path . LINETO ] * 3 + [ Path . CLOSEPOLY ] vertices = [( 1 , 1 ), ( 1 , 2 ), ( 2 , 2 ), ( 2 , 1 ), ( 0 , 0 )] codes += [ Path . MOVETO ] + [ Path . LINETO ] * 2 + [ Path .
CLOSEPOLY ] vertices += [( 4 , 4 ), ( 5 , 5 ), ( 5 , 4 ), ( 0 , 0 )] vertices = np . array ( vertices , float ) path = Path ( vertices , codes ) pathpatch = PathPatch ( path , facecolor = 'None' , edgecolor = 'green' ) fig , ax = plt . subplots () ax . add_patch ( pathpatch ) ax . set_title ( 'A compound path' ) ax . dataLim . update_from_data_xy ( vertices ) ax . autoscale_view () plt . show () Keywords: python, matplotlib, pylab, example, codex (see Search examples ) © Copyright 2002 - 2012 John Hunter, Darren Dale, Eric Firing, Michael Droettboom and the Matplotlib development team; 2012 - 2016 The Matplotlib development team.
Last updated on May 10, 2017. Created using Sphinx 1.5.5.