Skip to content

Stop recommending ncol in legend examples #25110

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def survey(results, category_names):
r, g, b, _ = color
text_color = 'white' if r * g * b < 0.5 else 'darkgrey'
ax.bar_label(rects, label_type='center', color=text_color)
ax.legend(ncol=len(category_names), bbox_to_anchor=(0, 1),
ax.legend(ncols=len(category_names), bbox_to_anchor=(0, 1),
loc='lower left', fontsize='small')

return fig, ax
Expand Down
2 changes: 1 addition & 1 deletion examples/text_labels_and_annotations/legend_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
for n in range(1, 5):
ax0.plot(x, x**n, label=f"{n=}")
leg = ax0.legend(loc="upper left", bbox_to_anchor=[0, 1],
ncol=2, shadow=True, title="Legend", fancybox=True)
ncols=2, shadow=True, title="Legend", fancybox=True)
leg.get_title().set_color("red")

# Demonstrate some more complex labels.
Expand Down
2 changes: 1 addition & 1 deletion examples/user_interfaces/mplcvd.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,5 +295,5 @@ def _setup_wx(tb):
th = np.linspace(0, 2*np.pi, 1024)
for j in [1, 2, 4, 6]:
axd['lines'].plot(th, np.sin(th * j), label=f'$\\omega={j}$')
axd['lines'].legend(ncol=2, loc='upper right')
axd['lines'].legend(ncols=2, loc='upper right')
plt.show()
2 changes: 1 addition & 1 deletion examples/userdemo/simple_legend01.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# Place a legend above this subplot, expanding itself to
# fully use the given bounding box.
ax.legend(bbox_to_anchor=(0., 1.02, 1., .102), loc='lower left',
ncol=2, mode="expand", borderaxespad=0.)
ncols=2, mode="expand", borderaxespad=0.)

ax = fig.add_subplot(223)
ax.plot([1, 2, 3], label="test1")
Expand Down
2 changes: 1 addition & 1 deletion tutorials/intermediate/legend_guide.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
# Place a legend above this subplot, expanding itself to
# fully use the given bounding box.
ax_dict['top'].legend(bbox_to_anchor=(0., 1.02, 1., .102), loc='lower left',
ncol=2, mode="expand", borderaxespad=0.)
ncols=2, mode="expand", borderaxespad=0.)

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