-
Notifications
You must be signed in to change notification settings - Fork 0
/
wavegraphics.py
53 lines (50 loc) · 1.84 KB
/
wavegraphics.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env python3
from matplotlib.patches import PathPatch
from matplotlib.path import Path
def frame_patch(xy, width, height, border_width, facecolor='none', hatch = '/', edgecolor = 'white'):
'''
Parameters
----------
xy : tuple
The coordinates of the bottom left corner of the rectangle.
width : float
The width of the outer rectangle.
height : float
The height of the outer rectangle.
border_width : float
The width of the frame.
facecolor : str, optional
The color of the rectangle.
hatch : str, optional
The hatch pattern of the rectangle.
Returns
-------
patch : matplotlib.patches.PathPatch
The patch to be added to the axes.
'''
path = Path([(xy[0] , xy[1]), # moveto
(xy[0] , xy[1] + height), # lineto
(xy[0] + width, xy[1] + height), # lineto
(xy[0] + width, xy[1]), # lineto
(0,0), # closepoly
(xy[0] + border_width , xy[1] + border_width), # moveto
(xy[0] + width - border_width, xy[1] + border_width), # lineto
(xy[0] + width - border_width, xy[1] + height - border_width), # lineto
(xy[0] + border_width , xy[1] + height - border_width), # lineto
(0,0) # closepoly
],
[Path.MOVETO,
Path.LINETO,
Path.LINETO,
Path.LINETO,
Path.CLOSEPOLY,
Path.MOVETO,
Path.LINETO,
Path.LINETO,
Path.LINETO,
Path.CLOSEPOLY])
patch = PathPatch(path,
facecolor=facecolor,
hatch=hatch,
edgecolor=edgecolor)
return patch