|
20 | 20 | fig, (ax,ax2)=plt.subplots(1,2,figsize=[5.5,2.8])
|
21 | 21 |
|
22 | 22 | # Create inset of width 1.3 inches and height 0.9 inches
|
23 |
| -# at the default upper right location |
| 23 | +# at the default upper right location. |
24 | 24 | axins=inset_axes(ax,width=1.3,height=0.9)
|
25 | 25 |
|
26 | 26 | # Create inset of width 30% and height 40% of the parent Axes' bounding box
|
27 |
| -# at the lower left corner (loc=3) |
28 |
| -axins2=inset_axes(ax,width="30%",height="40%",loc=3) |
| 27 | +# at the lower left corner. |
| 28 | +axins2=inset_axes(ax,width="30%",height="40%",loc="lower left") |
29 | 29 |
|
30 | 30 | # Create inset of mixed specifications in the second subplot;
|
31 | 31 | # width is 30% of parent Axes' bounding box and
|
32 |
| -# height is 1 inch at the upper left corner (loc=2) |
33 |
| -axins3=inset_axes(ax2,width="30%",height=1.,loc=2) |
| 32 | +# height is 1 inch at the upper left corner. |
| 33 | +axins3=inset_axes(ax2,width="30%",height=1.,loc="upper left") |
34 | 34 |
|
35 |
| -# Create an inset in the lower right corner(loc=4)with borderpad=1, i.e. |
36 |
| -# 10 points padding (as 10pt is the default fontsize) to the parent Axes |
37 |
| -axins4=inset_axes(ax2,width="20%",height="20%",loc=4,borderpad=1) |
| 35 | +# Create an inset in the lower right corner with borderpad=1, i.e. |
| 36 | +# 10 points padding (as 10pt is the default fontsize) to the parent Axes. |
| 37 | +axins4=inset_axes(ax2,width="20%",height="20%",loc="lower right",borderpad=1) |
38 | 38 |
|
39 | 39 | # Turn ticklabels of insets off
|
40 | 40 | foraxiin [axins,axins2,axins3,axins4]:
|
|
61 | 61 | # in those coordinates.
|
62 | 62 | # Inside this bounding box an inset of half the bounding box' width and
|
63 | 63 | # three quarters of the bounding box' height is created. The lower left corner
|
64 |
| -# of the inset is aligned to the lower left corner of the bounding box (loc=3). |
| 64 | +# of the inset is aligned to the lower left corner of the bounding box. |
65 | 65 | # The inset is then offset by the default 0.5 in units of the font size.
|
66 | 66 |
|
67 | 67 | axins=inset_axes(ax,width="50%",height="75%",
|
68 | 68 | bbox_to_anchor=(.2,.4,.6,.5),
|
69 |
| -bbox_transform=ax.transAxes,loc=3) |
| 69 | +bbox_transform=ax.transAxes,loc="lower left") |
70 | 70 |
|
71 | 71 | # For visualization purposes we mark the bounding box by a rectangle
|
72 | 72 | ax.add_patch(plt.Rectangle((.2,.4),.6,.5,ls="--",ec="c",fc="none",
|
|
113 | 113 | # Create an inset outside the Axes
|
114 | 114 | axins=inset_axes(ax,width="100%",height="100%",
|
115 | 115 | bbox_to_anchor=(1.05,.6,.5,.4),
|
116 |
| -bbox_transform=ax.transAxes,loc=2,borderpad=0) |
| 116 | +bbox_transform=ax.transAxes,loc="upper left",borderpad=0) |
117 | 117 | axins.tick_params(left=False,right=True,labelleft=False,labelright=True)
|
118 | 118 |
|
119 | 119 | # Create an inset with a 2-tuple bounding box. Note that this creates a
|
120 | 120 | # bbox without extent. This hence only makes sense when specifying
|
121 | 121 | # width and height in absolute units (inches).
|
122 | 122 | axins2=inset_axes(ax,width=0.5,height=0.4,
|
123 | 123 | bbox_to_anchor=(0.33,0.25),
|
124 |
| -bbox_transform=ax.transAxes,loc=3,borderpad=0) |
| 124 | +bbox_transform=ax.transAxes,loc="lower left",borderpad=0) |
125 | 125 |
|
126 | 126 |
|
127 | 127 | ax2=fig.add_subplot(133)
|
|
131 | 131 | # Create inset in data coordinates using ax.transData as transform
|
132 | 132 | axins3=inset_axes(ax2,width="100%",height="100%",
|
133 | 133 | bbox_to_anchor=(1e-2,2,1e3,3),
|
134 |
| -bbox_transform=ax2.transData,loc=2,borderpad=0) |
| 134 | +bbox_transform=ax2.transData,loc="upper left",borderpad=0) |
135 | 135 |
|
136 | 136 | # Create an inset horizontally centered in figure coordinates and vertically
|
137 | 137 | # bound to line up with the Axes.
|
|
140 | 140 | transform=blended_transform_factory(fig.transFigure,ax2.transAxes)
|
141 | 141 | axins4=inset_axes(ax2,width="16%",height="34%",
|
142 | 142 | bbox_to_anchor=(0,0,1,1),
|
143 |
| -bbox_transform=transform,loc=8,borderpad=0) |
| 143 | +bbox_transform=transform,loc="lower center",borderpad=0) |
144 | 144 |
|
145 | 145 | plt.show()
|