""" Plotting helpers. * We set the default tick_formatter to 'latex'. * We replace the plot() function with our own version that sets some default legend options. """ from sage.all import * # Graphics.SHOW_OPTIONS contains the default options that will be # passed to show(). It already handles merging the user-specified # options, so we just tap into that power. show_opts = sage.plot.graphics.Graphics.SHOW_OPTIONS show_opts['tick_formatter'] = 'latex' # 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): """ Replacement for the default 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 } # Create an empty plot using the default options. p = Graphics() p.set_legend_options(**default_legend_opts) # After trac #12936, this should propagate those options. p += plot_impl(*args, **kwargs) return p # 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