File indexing completed on 2026-04-09 07:48:52
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021 """
0022 https://matplotlib.org/gallery/shapes_and_collections/path_patch.html
0023 """
0024 import matplotlib.path as mpath
0025 import matplotlib.patches as mpatches
0026 import matplotlib.pyplot as plt
0027
0028
0029 plt.ion()
0030
0031 fig, ax = plt.subplots()
0032
0033 Path = mpath.Path
0034
0035 """
0036
0037 path_data = [
0038 (Path.MOVETO, (1.58, -2.57)),
0039 (Path.CURVE4, (0.35, -1.1)),
0040 (Path.CURVE4, (-1.75, 2.0)),
0041 (Path.CURVE4, (0.375, 2.0)),
0042 (Path.LINETO, (0.85, 1.15)),
0043 (Path.CURVE4, (2.2, 3.2)),
0044 (Path.CURVE4, (3, 0.05)),
0045 (Path.CURVE4, (2.0, -0.5)),
0046 (Path.CLOSEPOLY, (1.58, -2.57)),
0047 ]
0048
0049 """
0050
0051 """
0052
0053
0054
0055 +---|---+
0056 r1
0057 """
0058
0059 r1 = 10
0060 r2 = 20
0061 hz = 5
0062
0063 z2 = hz
0064 z1 = -hz
0065
0066 path_data = [
0067 (Path.MOVETO, ( -r1, z1)),
0068 (Path.LINETO, ( -r2, z2)),
0069 (Path.LINETO, ( r2, z2)),
0070 (Path.LINETO, ( r1, z1)),
0071 (Path.CLOSEPOLY, (-r1, z1)),
0072 ]
0073
0074 codes, verts = zip(*path_data)
0075 path = mpath.Path(verts, codes)
0076 patch = mpatches.PathPatch(path, fill=False)
0077 ax.add_patch(patch)
0078
0079
0080
0081
0082
0083
0084 ax.axis('equal')
0085 plt.show()