How to do it...

The following code block defines points and associated lines and curves to be drawn to form the overall picture:

  1. Define the points along with the 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
  1. Plot the graph connecting the points defined in step 1:
codes1 = [Path.MOVETO,    # Go to first point specified in vert1
Path.LINETO, # Draw a line from first point to second
point
Path.LINETO, # Draw another line from current point to
next point
Path.LINETO, # Draw another line from current point to
next point
Path.CLOSEPOLY] # Close the loop
  1. Create the complete path with points and lines/curves defined in step 1 and step 2:
path1 = Path(verts1, codes1)
  1. Repeat the same for the second curve:
verts2 = [(-1.5, 0.),       # left, bottom
(0., 2.5), # left, top
(1.5, 0.), # right, top
(0., -2.5), # right, bottom
(-1.5, 0.)] # ignored

codes2 = [Path.MOVETO, # Move to the first point
Path.CURVE3, # Curve from first point along the control
point and terminate on end point
Path.CURVE3, # Curve from current point along the control
point and terminate on end point
Path.CURVE3,
Path.CURVE3] # close by the curved loop

path2 = Path(verts2, codes2)

  1. Define the figure and the axes:
fig = plt.figure()
ax = fig.add_subplot(111)
  1. Create the first patch and add it to the axes:
patch1 = patches.PathPatch(path1, lw=4, zorder=2)
ax.add_patch(patch1)
  1. Create the second patch and add it to the axes:
patch2 = patches.PathPatch(path2, facecolor='orange', lw=2, 
zorder=1)
ax.add_patch(patch2)
  1. Set the limits for x and y axes:
ax.set_xlim(-2,2)
ax.set_ylim(-2,2)
  1. Display the plot on the screen:
plt.show()