1
- from typing import Callable , Optional , Iterable
1
+ from typing import Optional , Iterable , Type , Union
2
2
from matplotlib .artist import Artist
3
3
from matplotlib .axes import Axes
4
- from matplotview ._view_axes import view_wrapper , DEFAULT_RENDER_DEPTH
4
+ from matplotview ._view_axes import view_wrapper , ViewSpecification , DEFAULT_RENDER_DEPTH
5
+
6
+ __all__ = ["view" , "inset_zoom_axes" ]
5
7
6
8
def view (
7
9
axes : Axes ,
8
10
axes_to_view : Axes ,
9
11
image_interpolation : str = "nearest" ,
10
12
render_depth : int = DEFAULT_RENDER_DEPTH ,
11
- filter_function : Optional [Callable [[Artist ], bool ]] = None
13
+ filter_set : Optional [Iterable [Union [Type [Artist ], Artist ]]] = None ,
14
+ scale_lines : bool = True
12
15
) -> Axes :
13
16
"""
14
17
Convert an axes into a view of another axes, displaying the contents of
@@ -36,15 +39,21 @@ def view(
36
39
if the view is a child of the axes (such as an inset axes) or if
37
40
two views point at each other. Defaults to 5.
38
41
39
- filter_function: callable(Artist) -> bool or None
40
- An optional filter function, which can be used to select what artists
41
- are drawn by the view. If the function returns True, the element is
42
- drawn, otherwise it isn't. Defaults to None, or drawing all artists.
42
+ filter_set: Iterable[Union[Type[Artist], Artist]] or None
43
+ An optional filter set, which can be used to select what artists
44
+ are drawn by the view. Any artists types in the set are not drawn.
45
+
46
+ scale_lines: bool, defaults to True
47
+ Specifies if lines should be drawn thicker based on scaling in the
48
+ view.
43
49
"""
44
- return view_wrapper (type (axes )).from_axes (
45
- axes , axes_to_view , image_interpolation ,
46
- render_depth , filter_function
50
+ view_obj = view_wrapper (type (axes )).from_axes (axes , render_depth )
51
+ view_obj .view_specifications [axes_to_view ] = ViewSpecification (
52
+ image_interpolation ,
53
+ filter_set ,
54
+ scale_lines
47
55
)
56
+ return view_obj
48
57
49
58
50
59
def inset_zoom_axes (
@@ -53,7 +62,8 @@ def inset_zoom_axes(
53
62
* ,
54
63
image_interpolation = "nearest" ,
55
64
render_depth : int = DEFAULT_RENDER_DEPTH ,
56
- filter_function : Optional [Callable [[Artist ], bool ]] = None ,
65
+ filter_set : Optional [Iterable [Union [Type [Artist ], Artist ]]] = None ,
66
+ scale_lines : bool = True ,
57
67
transform = None ,
58
68
zorder = 5 ,
59
69
** kwargs
@@ -92,10 +102,13 @@ def inset_zoom_axes(
92
102
if the view is a child of the axes (such as an inset axes) or if
93
103
two views point at each other. Defaults to 5.
94
104
95
- filter_function: callable(Artist) -> bool or None
96
- An optional filter function, which can be used to select what artists
97
- are drawn by the view. If the function returns True, the element is
98
- drawn, otherwise it isn't. Defaults to None, or drawing all artists.
105
+ filter_set: Iterable[Union[Type[Artist], Artist]] or None
106
+ An optional filter set, which can be used to select what artists
107
+ are drawn by the view. Any artists types in the set are not drawn.
108
+
109
+ scale_lines: bool, defaults to True
110
+ Specifies if lines should be drawn thicker based on scaling in the
111
+ view.
99
112
100
113
**kwargs
101
114
Other keyword arguments are passed on to the child `.Axes`.
@@ -114,5 +127,5 @@ def inset_zoom_axes(
114
127
)
115
128
return view (
116
129
inset_ax , axes , image_interpolation ,
117
- render_depth , filter_function
130
+ render_depth , filter_set , scale_lines
118
131
)
0 commit comments