Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit abeae04

Browse files
committed
Stop recommending ncol in legend examples
Since 958e329 the preferred keyword for controlling the number of columns in a legend is `ncols`, but some code examples have still been using `ncol`.
1 parent a30c0b1 commit abeae04

File tree

5 files changed

+5
-5
lines changed

5 files changed

+5
-5
lines changed

examples/lines_bars_and_markers/horizontal_barchart_distribution.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def survey(results, category_names):
6060
r, g, b, _ = color
6161
text_color = 'white' if r * g * b < 0.5 else 'darkgrey'
6262
ax.bar_label(rects, label_type='center', color=text_color)
63-
ax.legend(ncol=len(category_names), bbox_to_anchor=(0, 1),
63+
ax.legend(ncols=len(category_names), bbox_to_anchor=(0, 1),
6464
loc='lower left', fontsize='small')
6565

6666
return fig, ax

examples/text_labels_and_annotations/legend_demo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
for n in range(1, 5):
4848
ax0.plot(x, x**n, label=f"{n=}")
4949
leg = ax0.legend(loc="upper left", bbox_to_anchor=[0, 1],
50-
ncol=2, shadow=True, title="Legend", fancybox=True)
50+
ncols=2, shadow=True, title="Legend", fancybox=True)
5151
leg.get_title().set_color("red")
5252

5353
# Demonstrate some more complex labels.

examples/user_interfaces/mplcvd.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,5 +295,5 @@ def _setup_wx(tb):
295295
th = np.linspace(0, 2*np.pi, 1024)
296296
for j in [1, 2, 4, 6]:
297297
axd['lines'].plot(th, np.sin(th * j), label=f'$\\omega={j}$')
298-
axd['lines'].legend(ncol=2, loc='upper right')
298+
axd['lines'].legend(ncols=2, loc='upper right')
299299
plt.show()

examples/userdemo/simple_legend01.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# Place a legend above this subplot, expanding itself to
1616
# fully use the given bounding box.
1717
ax.legend(bbox_to_anchor=(0., 1.02, 1., .102), loc='lower left',
18-
ncol=2, mode="expand", borderaxespad=0.)
18+
ncols=2, mode="expand", borderaxespad=0.)
1919

2020
ax = fig.add_subplot(223)
2121
ax.plot([1, 2, 3], label="test1")

tutorials/intermediate/legend_guide.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@
127127
# Place a legend above this subplot, expanding itself to
128128
# fully use the given bounding box.
129129
ax_dict['top'].legend(bbox_to_anchor=(0., 1.02, 1., .102), loc='lower left',
130-
ncol=2, mode="expand", borderaxespad=0.)
130+
ncols=2, mode="expand", borderaxespad=0.)
131131

132132
ax_dict['bottom'].plot([1, 2, 3], label="test1")
133133
ax_dict['bottom'].plot([3, 2, 1], label="test2")

0 commit comments

Comments
 (0)