Skip to content
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

Added example in documentation of set_legend_options #38120

Merged
merged 11 commits into from
Jul 24, 2024
14 changes: 12 additions & 2 deletions src/sage/plot/graphics.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ def legend(self, show=None):
sage: P.legend()
False
sage: P.legend(True)
sage: P # show with the legend
sage: P # show with the legend
Graphics object consisting of 1 graphics primitive
"""
if show is None:
Expand Down Expand Up @@ -428,7 +428,17 @@ def set_legend_options(self, **kwds):

::

sage: p.set_legend_options(loc=(0.5,0.5)); p # aligns the bottom of the box to the center # needs sage.symbolic
sage: p.set_legend_options(loc=(0.5,0.5)); p # aligns the bottom of the box to the center # needs sage.symbolic
Graphics object consisting of 1 graphics primitive

The parameters ``loc`` and ``borderaxespad`` can be altered
in order to place the legend below the x-axis label or to
the left of the y-axis label::

sage: p = line([(0, 0), (1, 1)], legend_label='test')
sage: p.axes_labels(['X-Label', 'Y-Label']) # adding labels for axes
sage: p.set_legend_options(loc=8, borderaxespad=-7.5-0.01*p.fontsize())
sage: p
Graphics object consisting of 1 graphics primitive
"""
if len(kwds) == 0:
Expand Down
Loading