Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6ea50c8

Browse files
committed
Replace numeric loc by position string
1 parentdd5f241 commit6ea50c8

File tree

31 files changed

+81
-79
lines changed

31 files changed

+81
-79
lines changed

‎doc/users/prev_whats_new/whats_new_2.1.0.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -261,11 +261,11 @@ rectangle for the size bar.
261261

262262
fig, ax = plt.subplots(figsize=(3, 3))
263263

264-
bar0 = AnchoredSizeBar(ax.transData, 0.3, 'unfilled', loc=3, frameon=False,
265-
size_vertical=0.05, fill_bar=False)
264+
bar0 = AnchoredSizeBar(ax.transData, 0.3, 'unfilled', loc='lower left',
265+
frameon=False,size_vertical=0.05, fill_bar=False)
266266
ax.add_artist(bar0)
267-
bar1 = AnchoredSizeBar(ax.transData, 0.3, 'filled', loc=4, frameon=False,
268-
size_vertical=0.05, fill_bar=True)
267+
bar1 = AnchoredSizeBar(ax.transData, 0.3, 'filled', loc='lower right',
268+
frameon=False,size_vertical=0.05, fill_bar=True)
269269
ax.add_artist(bar1)
270270

271271
plt.show()

‎examples/axes_grid1/demo_anchored_direction_arrows.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
high_contrast_part_1=AnchoredDirectionArrows(
2121
ax.transAxes,
2222
'111',r'11$\overline{2}$',
23-
loc=1,
23+
loc='upper right',
2424
arrow_props={'ec':'w','fc':'none','alpha':1,
2525
'lw':2}
2626
)
@@ -29,7 +29,7 @@
2929
high_contrast_part_2=AnchoredDirectionArrows(
3030
ax.transAxes,
3131
'111',r'11$\overline{2}$',
32-
loc=1,
32+
loc='upper right',
3333
arrow_props={'ec':'none','fc':'k'},
3434
text_props={'ec':'w','fc':'k','lw':0.4}
3535
)

‎examples/axes_grid1/demo_axes_grid2.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def add_inner_title(ax, title, loc, size=None, **kwargs):
6060
ax.cax.colorbar(im)
6161

6262
forax,im_titleinzip(grid, ["Image 1","Image 2","Image 3"]):
63-
t=add_inner_title(ax,im_title,loc=3)
63+
t=add_inner_title(ax,im_title,loc='lower left')
6464
t.patch.set_alpha(0.5)
6565

6666
forax,zinzip(grid,ZS):
@@ -109,7 +109,7 @@ def add_inner_title(ax, title, loc, size=None, **kwargs):
109109
ax.cax.toggle_label(True)
110110

111111
forax,im_titleinzip(grid2, ["(a)","(b)","(c)"]):
112-
t=add_inner_title(ax,im_title,loc=2)
112+
t=add_inner_title(ax,im_title,loc='upper left')
113113
t.patch.set_ec("none")
114114
t.patch.set_alpha(0.5)
115115

‎examples/axes_grid1/demo_colorbar_of_inset_axes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def get_demo_image():
2828
ylim=(-20,5))
2929

3030

31-
axins=zoomed_inset_axes(ax,2,loc=2)# zoom = 6
31+
axins=zoomed_inset_axes(ax,zoom=2,loc='upper left')
3232
im=axins.imshow(Z,extent=extent,interpolation="nearest",
3333
origin="lower")
3434

@@ -40,7 +40,7 @@ def get_demo_image():
4040
cax=inset_axes(axins,
4141
width="5%",# width = 10% of parent_bbox width
4242
height="100%",# height : 50%
43-
loc=3,
43+
loc='lower left',
4444
bbox_to_anchor=(1.05,0.,1,1),
4545
bbox_transform=axins.transAxes,
4646
borderpad=0,

‎examples/axes_grid1/demo_colorbar_with_inset_locator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
axins1=inset_axes(ax1,
1414
width="50%",# width = 10% of parent_bbox width
1515
height="5%",# height : 50%
16-
loc=1)
16+
loc='upper right')
1717

1818
im1=ax1.imshow([[1,2], [2,3]])
1919
plt.colorbar(im1,cax=axins1,orientation="horizontal",ticks=[1,2,3])
@@ -22,7 +22,7 @@
2222
axins=inset_axes(ax2,
2323
width="5%",# width = 10% of parent_bbox width
2424
height="50%",# height : 50%
25-
loc=3,
25+
loc='lower left',
2626
bbox_to_anchor=(1.05,0.,1,1),
2727
bbox_transform=ax2.transAxes,
2828
borderpad=0,

‎examples/axes_grid1/inset_locator_demo.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def add_sizebar(ax, size):
1414
asb=AnchoredSizeBar(ax.transData,
1515
size,
1616
str(size),
17-
loc=8,
17+
loc='lower center',
1818
pad=0.1,borderpad=0.5,sep=5,
1919
frameon=False)
2020
ax.add_artist(asb)
@@ -28,7 +28,7 @@ def add_sizebar(ax, size):
2828
axins=inset_axes(ax,
2929
width="30%",# width = 30% of parent_bbox
3030
height=1.,# height : 1 inch
31-
loc=3)
31+
loc='lower left')
3232

3333
plt.xticks(visible=False)
3434
plt.yticks(visible=False)

‎examples/axes_grid1/inset_locator_demo2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def get_demo_image():
3232
ax.imshow(Z2,extent=extent,interpolation="nearest",
3333
origin="lower")
3434

35-
axins=zoomed_inset_axes(ax,6,loc=1)# zoom = 6
35+
axins=zoomed_inset_axes(ax,zoom=6,loc='upper right')
3636
axins.imshow(Z2,extent=extent,interpolation="nearest",
3737
origin="lower")
3838

‎examples/axes_grid1/simple_anchored_artists.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,14 @@ def draw_text(ax):
1818
corner of the figure.
1919
"""
2020
frommatplotlib.offsetboximportAnchoredText
21-
# loc=2 is equivalent to loc='upper left'
2221
at=AnchoredText("Figure 1a",
23-
loc=2,prop=dict(size=8),frameon=True,
22+
loc='upper left',prop=dict(size=8),frameon=True,
2423
)
2524
at.patch.set_boxstyle("round,pad=0.,rounding_size=0.2")
2625
ax.add_artist(at)
2726

28-
# loc=3 is eqivalent to loc='lower left'
2927
at2=AnchoredText("Figure 1(b)",
30-
loc=3,prop=dict(size=8),frameon=True,
28+
loc='lower left',prop=dict(size=8),frameon=True,
3129
bbox_to_anchor=(0.,1.),
3230
bbox_transform=ax.transAxes
3331
)
@@ -42,7 +40,7 @@ def draw_circle(ax):
4240
frommpl_toolkits.axes_grid1.anchored_artistsimportAnchoredDrawingArea
4341
frommatplotlib.patchesimportCircle
4442
ada=AnchoredDrawingArea(20,20,0,0,
45-
loc=1,pad=0.,frameon=False)
43+
loc='upper right',pad=0.,frameon=False)
4644
p=Circle((10,10),10)
4745
ada.da.add_artist(p)
4846
ax.add_artist(ada)
@@ -54,7 +52,8 @@ def draw_ellipse(ax):
5452
"""
5553
frommpl_toolkits.axes_grid1.anchored_artistsimportAnchoredEllipse
5654
ae=AnchoredEllipse(ax.transData,width=0.1,height=0.15,angle=0.,
57-
loc=3,pad=0.5,borderpad=0.4,frameon=True)
55+
loc='lower left',pad=0.5,borderpad=0.4,
56+
frameon=True)
5857

5958
ax.add_artist(ae)
6059

@@ -68,7 +67,7 @@ def draw_sizebar(ax):
6867
asb=AnchoredSizeBar(ax.transData,
6968
0.1,
7069
r"1$^{\prime}$",
71-
loc=8,
70+
loc='lower center',
7271
pad=0.1,borderpad=0.5,sep=5,
7372
frameon=False)
7473
ax.add_artist(asb)

‎examples/lines_bars_and_markers/markevery_prop_cycle.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555

5656
foriinrange(len(cases)):
5757
ax.plot(yy[:,i],marker='o',label=str(cases[i]))
58-
ax.legend(bbox_to_anchor=(1.05,1),loc=2,borderaxespad=0.)
58+
ax.legend(bbox_to_anchor=(1.05,1),loc='upper left',borderaxespad=0.)
5959

6060
plt.title('Support for axes.prop_cycle cycler with markevery')
6161

‎examples/lines_bars_and_markers/scatter_symbol.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@
2222
label="Luck")
2323
plt.xlabel("Leprechauns")
2424
plt.ylabel("Gold")
25-
plt.legend(loc=2)
25+
plt.legend(loc='upper left')
2626
plt.show()

‎examples/lines_bars_and_markers/stackplot_demo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
fig,ax=plt.subplots()
2525
ax.stackplot(x,y1,y2,y3,labels=labels)
26-
ax.legend(loc=2)
26+
ax.legend(loc='upper left')
2727
plt.show()
2828

2929
fig,ax=plt.subplots()

‎examples/misc/anchored_artists.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ def draw_text(ax):
2929
"""
3030
Draw a text-box anchored to the upper-left corner of the figure.
3131
"""
32-
# loc=2 is equivalent to loc='upper left'
33-
at=AnchoredText("Figure 1a",loc=2,frameon=True)
32+
at=AnchoredText("Figure 1a",loc='upper left',frameon=True)
3433
at.patch.set_boxstyle("round,pad=0.,rounding_size=0.2")
3534
ax.add_artist(at)
3635

@@ -49,7 +48,7 @@ def draw_circle(ax):
4948
"""
5049
frommatplotlib.patchesimportCircle
5150
ada=AnchoredDrawingArea(20,20,0,0,
52-
loc=1,pad=0.,frameon=False)
51+
loc='upper right',pad=0.,frameon=False)
5352
p=Circle((10,10),10)
5453
ada.da.add_artist(p)
5554
ax.add_artist(ada)
@@ -75,7 +74,8 @@ def draw_ellipse(ax):
7574
Draw an ellipse of width=0.1, height=0.15 in data coordinates
7675
"""
7776
ae=AnchoredEllipse(ax.transData,width=0.1,height=0.15,angle=0.,
78-
loc=3,pad=0.5,borderpad=0.4,frameon=True)
77+
loc='lower left',pad=0.5,borderpad=0.4,
78+
frameon=True)
7979

8080
ax.add_artist(ae)
8181

@@ -111,7 +111,7 @@ def draw_sizebar(ax):
111111
asb=AnchoredSizeBar(ax.transData,
112112
0.1,
113113
r"1$^{\prime}$",
114-
loc=8,
114+
loc='lower center',
115115
pad=0.1,borderpad=0.5,sep=5,
116116
frameon=False)
117117
ax.add_artist(asb)

‎examples/misc/patheffect_demo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
# shadow as a path effect
4242
ax3=plt.subplot(133)
4343
p1,=ax3.plot([0,1], [0,1])
44-
leg=ax3.legend([p1], ["Line 1"],fancybox=True,loc=2)
44+
leg=ax3.legend([p1], ["Line 1"],fancybox=True,loc='upper left')
4545
leg.legendPatch.set_path_effects([PathEffects.withSimplePatchShadow()])
4646

4747
plt.show()

‎examples/text_labels_and_annotations/demo_text_path.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ def draw(self, renderer=None):
8181
offsetbox.add_artist(p)
8282

8383
# make anchored offset box
84-
ao=AnchoredOffsetbox(loc=2,child=offsetbox,frameon=True,borderpad=0.2)
84+
ao=AnchoredOffsetbox(loc='upper left',child=offsetbox,frameon=True,
85+
borderpad=0.2)
8586
ax.add_artist(ao)
8687

8788
# another text

‎examples/userdemo/anchored_box01.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
fig,ax=plt.subplots(figsize=(3,3))
1212

1313
at=AnchoredText("Figure 1a",
14-
prop=dict(size=15),frameon=True,loc=2)
14+
prop=dict(size=15),frameon=True,loc='upper left')
1515
at.patch.set_boxstyle("round,pad=0.,rounding_size=0.2")
1616
ax.add_artist(at)
1717

‎examples/userdemo/anchored_box02.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
fig,ax=plt.subplots(figsize=(3,3))
1313

1414
ada=AnchoredDrawingArea(40,20,0,0,
15-
loc=1,pad=0.,frameon=False)
15+
loc='upper right',pad=0.,frameon=False)
1616
p1=Circle((10,10),10)
1717
ada.drawing_area.add_artist(p1)
1818
p2=Circle((30,10),5,fc="r")

‎examples/userdemo/anchored_box03.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
fig,ax=plt.subplots(figsize=(3,3))
1313

14-
box=AnchoredAuxTransformBox(ax.transData,loc=2)
14+
box=AnchoredAuxTransformBox(ax.transData,loc='upper left')
1515
el=Ellipse((0,0),width=0.1,height=0.4,angle=30)# in data coordinates!
1616
box.drawing_area.add_artist(el)
1717

‎examples/userdemo/anchored_box04.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
align="center",
2727
pad=0,sep=5)
2828

29-
anchored_box=AnchoredOffsetbox(loc=3,
29+
anchored_box=AnchoredOffsetbox(loc='lower left',
3030
child=box,pad=0.,
3131
frameon=True,
3232
bbox_to_anchor=(0.,1.02),

‎examples/userdemo/simple_legend01.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
plt.plot([3,2,1],label="test2")
1313
# Place a legend above this subplot, expanding itself to
1414
# fully use the given bounding box.
15-
plt.legend(bbox_to_anchor=(0.,1.02,1.,.102),loc=3,
15+
plt.legend(bbox_to_anchor=(0.,1.02,1.,.102),loc='lower left',
1616
ncol=2,mode="expand",borderaxespad=0.)
1717

1818
plt.subplot(223)
1919
plt.plot([1,2,3],label="test1")
2020
plt.plot([3,2,1],label="test2")
2121
# Place a legend to the right of this smaller subplot.
22-
plt.legend(bbox_to_anchor=(1.05,1),loc=2,borderaxespad=0.)
22+
plt.legend(bbox_to_anchor=(1.05,1),loc='upper left',borderaxespad=0.)
2323

2424
plt.show()

‎examples/userdemo/simple_legend02.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
line2,=ax.plot([3,2,1],label="Line 2",linewidth=4)
1313

1414
# Create a legend for the first line.
15-
first_legend=ax.legend(handles=[line1],loc=1)
15+
first_legend=ax.legend(handles=[line1],loc='upper right')
1616

1717
# Add the legend manually to the current Axes.
1818
ax.add_artist(first_legend)
1919

2020
# Create another legend for the second line.
21-
ax.legend(handles=[line2],loc=4)
21+
ax.legend(handles=[line2],loc='lower right')
2222

2323
plt.show()

‎lib/matplotlib/tests/test_bbox_tight.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def test_bbox_inches_tight():
4343
remove_text=False,savefig_kwarg={'bbox_inches':'tight'})
4444
deftest_bbox_inches_tight_suptile_legend():
4545
plt.plot(np.arange(10),label='a straight line')
46-
plt.legend(bbox_to_anchor=(0.9,1),loc=2,)
46+
plt.legend(bbox_to_anchor=(0.9,1),loc='upper lefr')
4747
plt.title('Axis title')
4848
plt.suptitle('Figure title')
4949

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp