1+ from __future__ import print_function
2+
3+ import numpy as np
4+
15from matplotlib import rcParams , rcParamsDefault
26from matplotlib .testing .decorators import image_comparison
37import matplotlib .pyplot as plt
48import matplotlib .path as mpath
59import matplotlib .patches as mpatches
610from matplotlib .ticker import FuncFormatter
7- import numpy as np
11+
812
913@image_comparison (baseline_images = ['bbox_inches_tight' ], remove_text = True ,
1014 savefig_kwarg = dict (bbox_inches = 'tight' ), tol = 15 )
1115def test_bbox_inches_tight ():
12- " Test that a figure saved using bbox_inches'tight' is clipped right"
16+ #: Test that a figure saved using bbox_inches= 'tight' is clipped right
1317 rcParams .update (rcParamsDefault )
1418
15- data = [[ 66386 , 174296 , 75131 , 577908 , 32015 ],
16- [ 58230 , 381139 , 78045 , 99308 , 160454 ],
17- [ 89135 , 80552 , 152558 , 497981 , 603535 ],
18- [ 78415 , 81858 , 150656 , 193263 , 69638 ],
19- [ 139361 , 331509 , 343164 , 781380 , 52269 ]]
19+ data = [[66386 , 174296 , 75131 , 577908 , 32015 ],
20+ [58230 , 381139 , 78045 , 99308 , 160454 ],
21+ [89135 , 80552 , 152558 , 497981 , 603535 ],
22+ [78415 , 81858 , 150656 , 193263 , 69638 ],
23+ [139361 , 331509 , 343164 , 781380 , 52269 ]]
2024
2125 colLabels = rowLabels = ['' ] * 5
2226
@@ -26,13 +30,13 @@ def test_bbox_inches_tight():
2630 width = 0.4 # the width of the bars
2731 yoff = np .array ([0.0 ] * len (colLabels ))
2832 # the bottom values for stacked bar chart
29- fig , ax = plt .subplots (1 ,1 )
33+ fig , ax = plt .subplots (1 , 1 )
3034 for row in xrange (rows ):
3135 plt .bar (ind , data [row ], width , bottom = yoff )
3236 yoff = yoff + data [row ]
3337 cellText .append (['' ])
3438 plt .xticks ([])
35- plt .legend (['' ] * 5 , loc = (1.2 , 0.2 ))
39+ plt .legend (['' ] * 5 , loc = (1.2 , 0.2 ))
3640 # Add a table at the bottom of the axes
3741 cellText .reverse ()
3842 the_table = plt .table (cellText = cellText ,
@@ -71,8 +75,8 @@ def test_bbox_inches_tight_clipping():
7175
7276 # make a massive rectangle and clip it with a path
7377 patch = mpatches .Rectangle ([- 50 , - 50 ], 100 , 100 ,
74- transform = ax .transData ,
75- facecolor = 'blue' , alpha = 0.5 )
78+ transform = ax .transData ,
79+ facecolor = 'blue' , alpha = 0.5 )
7680
7781 path = mpath .Path .unit_regular_star (5 ).deepcopy ()
7882 path .vertices *= 0.25
0 commit comments