9
9
from mpl_toolkits .axes_grid1 import host_subplot
10
10
from mpl_toolkits .axes_grid1 import make_axes_locatable
11
11
from mpl_toolkits .axes_grid1 import AxesGrid
12
- from mpl_toolkits .axes_grid1 .inset_locator import zoomed_inset_axes , mark_inset , \
13
- BboxConnectorPatch
12
+ from mpl_toolkits .axes_grid1 .inset_locator import zoomed_inset_axes , \
13
+ mark_inset , BboxConnectorPatch
14
14
from mpl_toolkits .axes_grid1 .anchored_artists import AnchoredSizeBar
15
15
16
16
from matplotlib .colors import LogNorm
17
- from matplotlib .transforms import Bbox , TransformedBbox , blended_transform_factory
17
+ from matplotlib .transforms import Bbox , TransformedBbox , \
18
+ blended_transform_factory
18
19
from itertools import product
19
20
20
21
import numpy as np
@@ -158,7 +159,7 @@ def get_demo_image():
158
159
159
160
160
161
@image_comparison (
161
- baseline_images = ['fill_facecolor' ], extensions = ['png' ])
162
+ baseline_images = ['fill_facecolor' ], extensions = ['png' ])
162
163
def test_fill_facecolor ():
163
164
fig , ax = plt .subplots (1 , 5 )
164
165
fig .set_size_inches (5 , 5 )
@@ -172,73 +173,73 @@ def test_fill_facecolor():
172
173
ax [4 ].yaxis .tick_right ()
173
174
bbox = Bbox .from_extents (0 , 0.4 , 1 , 0.6 )
174
175
175
- # fill with blue by setting 'fc' field
176
- bbox1 = TransformedBbox (bbox , trans1 )
176
+ # fill with blue by setting 'fc' field
177
+ bbox1 = TransformedBbox (bbox , trans1 )
177
178
bbox2 = TransformedBbox (bbox , trans2 )
178
179
# set color to BboxConnectorPatch
179
- p = BboxConnectorPatch (bbox1 , bbox2 ,
180
- loc1a = 1 , loc2a = 2 , loc1b = 4 , loc2b = 3 ,
181
- ec = "r" , fc = "b" )
182
- p .set_clip_on (False )
183
- ax [0 ].add_patch (p )
184
- # set color to marked area
185
- axins = zoomed_inset_axes (ax [0 ], 1 , loc = 1 )
186
- axins .set_xlim (0 , 0.2 )
187
- axins .set_ylim (0 , 0.2 )
188
- plt .gca ().axes .get_xaxis ().set_ticks ([])
189
- plt .gca ().axes .get_yaxis ().set_ticks ([])
190
- mark_inset (ax [0 ], axins , loc1 = 2 , loc2 = 4 , fc = "b" , ec = "0.5" )
191
-
192
- # fill with yellow by setting 'facecolor' field
193
- bbox3 = TransformedBbox (bbox , trans2 )
194
- bbox4 = TransformedBbox (bbox , trans3 )
195
- # set color to BboxConnectorPatch
196
- p = BboxConnectorPatch (bbox3 , bbox4 ,
197
- loc1a = 1 , loc2a = 2 , loc1b = 4 , loc2b = 3 ,
198
- ec = "r" , facecolor = "y" )
199
- p .set_clip_on (False )
200
- ax [1 ].add_patch (p )
201
- # set color to marked area
202
- axins = zoomed_inset_axes (ax [1 ], 1 , loc = 1 )
203
- axins .set_xlim (0 , 0.2 )
204
- axins .set_ylim (0 , 0.2 )
205
- plt .gca ().axes .get_xaxis ().set_ticks ([])
206
- plt .gca ().axes .get_yaxis ().set_ticks ([])
207
- mark_inset (ax [1 ], axins , loc1 = 2 , loc2 = 4 , facecolor = "y" , ec = "0.5" )
208
-
209
- # fill with green by setting 'color' field
210
- bbox5 = TransformedBbox (bbox , trans3 )
211
- bbox6 = TransformedBbox (bbox , trans4 )
212
- # set color to BboxConnectorPatch
213
- p = BboxConnectorPatch (bbox5 , bbox6 ,
214
- loc1a = 1 , loc2a = 2 , loc1b = 4 , loc2b = 3 ,
215
- ec = "r" , color = "g" )
216
- p .set_clip_on (False )
217
- ax [2 ].add_patch (p )
218
- # set color to marked area
219
- axins = zoomed_inset_axes (ax [2 ], 1 , loc = 1 )
220
- axins .set_xlim (0 , 0.2 )
221
- axins .set_ylim (0 , 0.2 )
222
- plt .gca ().axes .get_xaxis ().set_ticks ([])
223
- plt .gca ().axes .get_yaxis ().set_ticks ([])
224
- mark_inset (ax [2 ], axins , loc1 = 2 , loc2 = 4 , color = "g" , ec = "0.5" )
225
-
226
- # fill with green but color won't show if set fill to False
227
- bbox7 = TransformedBbox (bbox , trans4 )
228
- bbox8 = TransformedBbox (bbox , trans5 )
229
- # BboxConnectorPatch won't show green
230
- p = BboxConnectorPatch (bbox7 , bbox8 ,
231
- loc1a = 1 , loc2a = 2 , loc1b = 4 , loc2b = 3 ,
232
- ec = "r" , fc = "g" , fill = False )
233
- p .set_clip_on (False )
234
- ax [3 ].add_patch (p )
235
- # marked area won't show green
236
- axins = zoomed_inset_axes (ax [3 ], 1 , loc = 1 )
237
- axins .set_xlim (0 , 0.2 )
238
- axins .set_ylim (0 , 0.2 )
239
- plt .gca ().axes .get_xaxis ().set_ticks ([])
240
- plt .gca ().axes .get_yaxis ().set_ticks ([])
241
- mark_inset (ax [3 ], axins , loc1 = 2 , loc2 = 4 , fc = "g" , ec = "0.5" , fill = False )
180
+ p = BboxConnectorPatch (
181
+ bbox1 , bbox2 , loc1a = 1 , loc2a = 2 , loc1b = 4 , loc2b = 3 ,
182
+ ec = "r" , fc = "b" )
183
+ p .set_clip_on (False )
184
+ ax [0 ].add_patch (p )
185
+ # set color to marked area
186
+ axins = zoomed_inset_axes (ax [0 ], 1 , loc = 1 )
187
+ axins .set_xlim (0 , 0.2 )
188
+ axins .set_ylim (0 , 0.2 )
189
+ plt .gca ().axes .get_xaxis ().set_ticks ([])
190
+ plt .gca ().axes .get_yaxis ().set_ticks ([])
191
+ mark_inset (ax [0 ], axins , loc1 = 2 , loc2 = 4 , fc = "b" , ec = "0.5" )
192
+
193
+ # fill with yellow by setting 'facecolor' field
194
+ bbox3 = TransformedBbox (bbox , trans2 )
195
+ bbox4 = TransformedBbox (bbox , trans3 )
196
+ # set color to BboxConnectorPatch
197
+ p = BboxConnectorPatch (
198
+ bbox3 , bbox4 , loc1a = 1 , loc2a = 2 , loc1b = 4 , loc2b = 3 ,
199
+ ec = "r" , facecolor = "y" )
200
+ p .set_clip_on (False )
201
+ ax [1 ].add_patch (p )
202
+ # set color to marked area
203
+ axins = zoomed_inset_axes (ax [1 ], 1 , loc = 1 )
204
+ axins .set_xlim (0 , 0.2 )
205
+ axins .set_ylim (0 , 0.2 )
206
+ plt .gca ().axes .get_xaxis ().set_ticks ([])
207
+ plt .gca ().axes .get_yaxis ().set_ticks ([])
208
+ mark_inset (ax [1 ], axins , loc1 = 2 , loc2 = 4 , facecolor = "y" , ec = "0.5" )
209
+
210
+ # fill with green by setting 'color' field
211
+ bbox5 = TransformedBbox (bbox , trans3 )
212
+ bbox6 = TransformedBbox (bbox , trans4 )
213
+ # set color to BboxConnectorPatch
214
+ p = BboxConnectorPatch (
215
+ bbox5 , bbox6 , loc1a = 1 , loc2a = 2 , loc1b = 4 , loc2b = 3 ,
216
+ ec = "r" , color = "g" )
217
+ p .set_clip_on (False )
218
+ ax [2 ].add_patch (p )
219
+ # set color to marked area
220
+ axins = zoomed_inset_axes (ax [2 ], 1 , loc = 1 )
221
+ axins .set_xlim (0 , 0.2 )
222
+ axins .set_ylim (0 , 0.2 )
223
+ plt .gca ().axes .get_xaxis ().set_ticks ([])
224
+ plt .gca ().axes .get_yaxis ().set_ticks ([])
225
+ mark_inset (ax [2 ], axins , loc1 = 2 , loc2 = 4 , color = "g" , ec = "0.5" )
226
+
227
+ # fill with green but color won't show if set fill to False
228
+ bbox7 = TransformedBbox (bbox , trans4 )
229
+ bbox8 = TransformedBbox (bbox , trans5 )
230
+ # BboxConnectorPatch won't show green
231
+ p = BboxConnectorPatch (
232
+ bbox7 , bbox8 , loc1a = 1 , loc2a = 2 , loc1b = 4 , loc2b = 3 ,
233
+ ec = "r" , fc = "g" , fill = False )
234
+ p .set_clip_on (False )
235
+ ax [3 ].add_patch (p )
236
+ # marked area won't show green
237
+ axins = zoomed_inset_axes (ax [3 ], 1 , loc = 1 )
238
+ axins .set_xlim (0 , 0.2 )
239
+ axins .set_ylim (0 , 0.2 )
240
+ plt .gca ().axes .get_xaxis ().set_ticks ([])
241
+ plt .gca ().axes .get_yaxis ().set_ticks ([])
242
+ mark_inset (ax [3 ], axins , loc1 = 2 , loc2 = 4 , fc = "g" , ec = "0.5" , fill = False )
242
243
243
244
244
245
@image_comparison (baseline_images = ['zoomed_axes' ,
0 commit comments