Path
Path is a method provided by matplotlib for drawing custom charts. It uses a helper function patch that is provided by matplotlib. Let us see how this can be used to draw a simple plot.
Getting ready
Import required libraries. Two new packages Path and Patch will be introduced here:
import matplotlib.pyplot as plt from matplotlib.path import Path import matplotlib.patches as patches
How to do it...
The following code block defines points and associated lines and curves to be drawn to form the over all picture:
# Define the points along with first curve to be drawn
verts1 = [(-1.5, 0.), # left, bottom
(0., 1.), # left, top
(1.5, 0.), # right, top
(0., -1.0), # right, bottom
(-1.5, 0.)] # ignored
# How to draw the plot along above points
codes1 = [Path.MOVETO, # Go to first point specified in vert1
Path.LINETO, # Draw a line from first point to second point
Path...