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
+list_plot_impl = sage.plot.plot.list_plot
def mjo_plot(*args, **kwargs):
"""
default_legend_opts = { 'back_color': 'white',
'shadow': True }
- # Create an empty plot using the default options.
- p = Graphics()
+ p = plot_impl(*args, **kwargs)
p.set_legend_options(**default_legend_opts)
- # After trac #12936, this should propagate those options.
- p += sage_plot(*args, **kwargs)
+ return p
+
+
+def mjo_list_plot(*args, **kwargs):
+ """
+ Replacement for the default list_plot function.
+
+ - If there's a legend, set the background color to 'white' and
+ give it a drop shadow.
+
+ """
+ default_legend_opts = { 'back_color': 'white',
+ 'shadow': True }
+
+ p = list_plot_impl(*args, **kwargs)
+ p.set_legend_options(**default_legend_opts)
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()
+# and list_plot(); we just replace the two function that did the
+# actual implementations.
+sage.plot.plot._plot = mjo_plot
+sage.plot.plot.list_plot = mjo_list_plot