Skip to content

Commit

Permalink
Merge branch 'region_plot' of github.com:egourgoulhon/sage into optio…
Browse files Browse the repository at this point in the history
…ns_fix_in_contour_plot

This also fixes a bug in region_plot, so that plot_points are not
passed in calls to other functions via options.

This is because a @options decorator's argument are automatically popped
from "options" dict as soon as the function it decorates has an arg
with the same name.

In the change we reduce the number of positional arguments of
region_plot; thus the corresponding args of @options have to be popped
manually in the function body; we don't pop plot_points, to
pass it correctly in function calls.
  • Loading branch information
dimpase committed Sep 19, 2023
2 parents beb94bc + 80fd0a9 commit b7c6367
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/sage/plot/contour_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -1391,9 +1391,10 @@ def f(x,y):
raise ValueError("fill=%s is not supported" % options['fill'])


@options(frame=False, axes=True, legend_label=None, aspect_ratio=1)
def region_plot(f, xrange, yrange, plot_points=100, incol='blue', outcol=None, bordercol=None,
borderstyle=None, borderwidth=None, alpha=1, **options):
@options(plot_points=100, incol='blue', outcol=None, bordercol=None,
borderstyle=None, borderwidth=None, frame=False, axes=True,
legend_label=None, aspect_ratio=1, alpha=1)
def region_plot(f, xrange, yrange, **options):
r"""
``region_plot`` takes a boolean function of two variables, `f(x, y)`
and plots the region where f is True over the specified
Expand Down Expand Up @@ -1657,6 +1658,14 @@ def region_plot(f, xrange, yrange, plot_points=100, incol='blue', outcol=None, b
from warnings import warn
import numpy

plot_points = options['plot_points']
incol = options.pop('incol')
outcol = options.pop('outcol')
bordercol = options.pop('bordercol')
borderstyle = options.pop('borderstyle')
borderwidth = options.pop('borderwidth')
alpha = options.pop('alpha')

if not isinstance(f, (list, tuple)):
f = [f]

Expand All @@ -1675,9 +1684,9 @@ def region_plot(f, xrange, yrange, plot_points=100, incol='blue', outcol=None, b
if neqs and not bordercol:
bordercol = incol
if not f:
return implicit_plot(feqs[0], xrange, yrange, plot_points=plot_points,
fill=False, linewidth=borderwidth,
linestyle=borderstyle, color=bordercol, **options)
return implicit_plot(feqs[0], xrange, yrange, fill=False,
linewidth=borderwidth, linestyle=borderstyle,
color=bordercol, **options)
f_all, ranges = setup_for_eval_on_grid(feqs + f,
[xrange, yrange],
plot_points)
Expand Down

0 comments on commit b7c6367

Please sign in to comment.