From 2058780173b27773116403f88d5b9daf6ec21b47 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Sat, 12 May 2012 19:03:05 -0400 Subject: [PATCH] Try replacing _plot() instead of plot() so that plotting python functions works. --- mjo/plot.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/mjo/plot.py b/mjo/plot.py index b301e30..87fccb3 100644 --- a/mjo/plot.py +++ b/mjo/plot.py @@ -16,9 +16,9 @@ from sage.all import * show_opts = sage.plot.graphics.Graphics.SHOW_OPTIONS show_opts['tick_formatter'] = 'latex' -# Save the default plot() function so that we can call it within -# mjo_plot and not die of recursion. -sage_plot = plot +# Save the original implementation so that we can call it from +# within mjo_plot. +plot_impl = sage.plot.plot._plot def mjo_plot(*args, **kwargs): """ @@ -36,13 +36,11 @@ def mjo_plot(*args, **kwargs): p.set_legend_options(**default_legend_opts) # After trac #12936, this should propagate those options. - p += sage_plot(*args, **kwargs) - + p += plot_impl(*args, **kwargs) return p -# Replace both the global `plot` and the ones in the modules. I am -# unclear about why this is necessary, and don't care too much. -plot = mjo_plot -sage.plot.plot.plot = mjo_plot -sage.plot.all.plot = mjo_plot +# This way, we don't have to try to replace all of the calls to +# plot(); we just replace the one function that did the actual +# implementation. +sage.plot.plot._plot = mjo_plot -- 2.44.2