Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • Pandas
  • Numpy
  • Seaborn
  • Ploty
  • Data visualization
  • Data Analysis
  • Power BI
  • Tableau
  • Machine Learning
  • Deep Learning
  • NLP
  • Computer Vision
  • Data Science for Beginners
  • Data Science interview questions
  • Data analysis interview questions
  • NLP Interview questions
Open In App
Next Article:
Matplotlib.patches.Circle class in Python
Next article icon

Matplotlib.patches.PathPatch in Python

Last Updated : 27 Apr, 2020
Comments
Improve
Suggest changes
Like Article
Like
Report
Matplotlib is an amazing visualization library in Python for 2D plots of arrays. Matplotlib is a multi-platform data visualization library built on NumPy arrays and designed to work with the broader SciPy stack.

matplotlib.patches.PathPatch

The matplotlib.patches.PathPatch class used to draw general polycurve path patch.
Syntax: class matplotlib.patches.PathPatch(path, **kwargs) Parameter:
  • path: path is a matplotlib.path.Path object.
The below tables gives the list of valid kwargs arguments:
PROPERTY DESCRIPTION
agg_filter a filter function that takes a (m, n, 3) float array and a dpi value that returns a (m, n, 3) array
alpha float or None
animated bool
antialiased or aa unknown
capstyle {‘butt’, ’round’, ‘projecting’}
clip_box Bbox
clip_on bool
clip_path [(Path, Transform)|Patch|None]
color color or sequence of rgba tuples
contains callable
edgecolor or ec or edgecolors color or None or ‘auto’
facecolor or fc or facecolors color or None
figure figure
fill bool
gid str
hatch {‘/’, ‘\’, ‘|’, ‘-‘, ‘+’, ‘x’, ‘o’, ‘O’, ‘.’, ‘*’}
in_layout bool
joinstyle {‘miter’, ’round’, ‘bevel’}
linestyle or ls {‘-‘, ‘–‘, ‘-.’, ‘:’, ”, (offset, on-off-seq), …}
linewidth or linewidths or lw float or None
path_effects AbstractPathEffect
picker None or bool or float or callable
path_effects AbstractPathEffect
picker float or callable[[Artist, Event], Tuple[bool, dict]]
rasterized bool or None
sketch_params (scale: float, length: float, randomness: float)
snap bool or None
transform matplotlib.transforms.Transform
url str
visible bool
zorder float
Example 1: Python3 1==
import numpy as np import matplotlib.cm as cm import matplotlib.pyplot as plt import matplotlib.cbook as cbook from matplotlib.path import Path from matplotlib.patches import PathPatch   delta = 0.025 x = y = np.arange(-3.0, 3.0, delta) X, Y = np.meshgrid(x, y) Z1 = np.exp(-X**2 - Y**2) Z2 = np.exp(-(X - 1)**2 - (Y - 1)**2) Z = (Z1 - Z2) * 2  path = Path([[0, 1], [1, 0], [0, -1], [-1, 0], [0, 1]]) patch = PathPatch(path, facecolor ='none')  fig, ax = plt.subplots() ax.add_patch(patch)  im = ax.imshow(Z, interpolation ='bilinear', cmap = cm.gray,                origin ='lower', extent =[-3, 3, -3, 3],                clip_path = patch, clip_on = True) im.set_clip_path(patch)  plt.show() 
Output: Example 2: Python3 1==
import matplotlib.pyplot as plt  import numpy as np from matplotlib.path import Path from matplotlib.patches import PathPatch   fig = plt.figure()   ax = fig.add_subplot(111, aspect ='equal')  path = Path([[0, 0], [0, 1], [1, 0], [0, 0]]) patch = PathPatch(path, facecolor ='none') ax.add_patch(patch)   Z, Z2 = np.meshgrid(np.linspace(0, 1), np.linspace(0, 1))  im = plt.imshow(Z-Z2,                  interpolation ='bilinear',                  cmap = plt.cm.RdYlGn,                 origin ='lower',                 extent =[0, 1, 0, 1],                 clip_path = patch,                 clip_on = True)  im.set_clip_path(patch)  ax.set_xlim((0, 1))  ax.set_ylim((0, 1))   plt.show() 
Output:

Next Article
Matplotlib.patches.Circle class in Python

R

RajuKumar19
Improve
Article Tags :
  • Python
  • Write From Home
  • Python-Library
  • Python-matplotlib
  • Matplotlib patches-class
Practice Tags :
  • python

Similar Reads

  • matplotlib.pyplot.pcolormesh() in Python
    Matplotlib is a library in Python and it is numerical - mathematical extension for NumPy library. Pyplot is a state-based interface to a Matplotlib module which provides a MATLAB-like interface. matplotlib.pyplot.pcolormesh() Function: The pcolormesh() function in pyplot module of matplotlib library
    2 min read
  • matplotlib.patches.Rectangle in Python
    Matplotlib is an amazing visualization library in Python for 2D plots of arrays. Matplotlib is a multi-platform data visualization library built on NumPy arrays and designed to work with the broader SciPy stack. matplotlib.patches.Rectangle The matplotlib.patches.Rectangle class is used to rectangle
    2 min read
  • Matplotlib.patches.Wedge class in Python
    Matplotlib is an amazing visualization library in Python for 2D plots of arrays. Matplotlib is a multi-platform data visualization library built on NumPy arrays and designed to work with the broader SciPy stack.   matplotlib.patches.Wedge The matplotlib.patches.Wedge class is used to add wedge-shape
    3 min read
  • Matplotlib.patches.Circle class in Python
    Matplotlib is an amazing visualization library in Python for 2D plots of arrays. Matplotlib is a multi-platform data visualization library built on NumPy arrays and designed to work with the broader SciPy stack. matplotlib.patches.Circle The matplotlib.patches.Circle class is used to create a circul
    3 min read
  • Matplotlib.pyplot.gca() in Python
    Matplotlib is a library in Python and it is a numerical - mathematical extension for the NumPy library. Pyplot is a state-based interface to a Matplotlib module that provides a MATLAB-like interface.   matplotlib.pyplot.gca() Function The gca() function in pyplot module of matplotlib library is used
    2 min read
  • Matplotlib.pyplot.gcf() in Python
    Matplotlib is an amazing visualization library in Python for 2D plots of arrays. Matplotlib is a multi-platform data visualization library built on NumPy arrays and designed to work with the broader SciPy stack.  matplotlib.pyplot.gcf() matplotlib.pyplot.gcf() is primarily used to get the current fi
    2 min read
  • Matplotlib.patches.RegularPolygon class in Python
    Matplotlib is an amazing visualization library in Python for 2D plots of arrays. Matplotlib is a multi-platform data visualization library built on NumPy arrays and designed to work with the broader SciPy stack.   matplotlib.patches.RegularPolygon The matplotlib.patches.RegularPolygon class is used
    3 min read
  • Matplotlib.axes.Axes.add_patch() in Python
    Matplotlib is a library in Python and it is numerical - mathematical extension for NumPy library. The Axes Class contains most of the figure elements: Axis, Tick, Line2D, Text, Polygon, etc., and sets the coordinate system. And the instances of Axes supports callbacks through a callbacks attribute.
    2 min read
  • Matplotlib.patches.ArrowStyle class in Python
    Matplotlib is an amazing visualization library in Python for 2D plots of arrays. Matplotlib is a multi-platform data visualization library built on NumPy arrays and designed to work with the broader SciPy stack. matplotlib.patches.ArrowStyle The matplotlib.patches.ArrowStyle class is a container cla
    2 min read
  • Matplotlib.pyplot.copper() in Python
    Matplotlib is a library in Python and it is numerical - mathematical extension for NumPy library. Pyplot is a state-based interface to a Matplotlib module which provides a MATLAB-like interface. matplotlib.pyplot.copper() Function The copper() function in pyplot module of matplotlib library is used
    2 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences