Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-09 07:48:52

0001 #!/usr/bin/env python
0002 #
0003 # Copyright (c) 2019 Opticks Team. All Rights Reserved.
0004 #
0005 # This file is part of Opticks
0006 # (see https://bitbucket.org/simoncblyth/opticks).
0007 #
0008 # Licensed under the Apache License, Version 2.0 (the "License"); 
0009 # you may not use this file except in compliance with the License.  
0010 # You may obtain a copy of the License at
0011 #
0012 #   http://www.apache.org/licenses/LICENSE-2.0
0013 #
0014 # Unless required by applicable law or agreed to in writing, software 
0015 # distributed under the License is distributed on an "AS IS" BASIS, 
0016 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  
0017 # See the License for the specific language governing permissions and 
0018 # limitations under the License.
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)  # facecolor='r', alpha=0.5)
0077 ax.add_patch(patch)
0078 
0079 # plot control points and connecting lines
0080 #x, y = zip(*path.vertices)
0081 #line, = ax.plot(x, y, 'go-')
0082 
0083 #ax.grid()
0084 ax.axis('equal')
0085 plt.show()