]> gitweb.michael.orlitzky.com - sage.d.git/blob - mjo/plot.py
Allow tuples to be passed in square brackets.
[sage.d.git] / mjo / plot.py
1 """
2 Plotting helpers.
3
4 * We set the default tick_formatter to 'latex'.
5
6 * We replace the plot() function with our own version that sets some
7 default legend options.
8
9 """
10
11 from sage.all import *
12
13 # Graphics.SHOW_OPTIONS contains the default options that will be
14 # passed to show(). It already handles merging the user-specified
15 # options, so we just tap into that power.
16 show_opts = sage.plot.graphics.Graphics.SHOW_OPTIONS
17 show_opts['tick_formatter'] = 'latex'
18
19 # Save the original implementation so that we can call it from
20 # within mjo_plot.
21 plot_impl = sage.plot.plot._plot
22
23 def mjo_plot(*args, **kwargs):
24 """
25 Replacement for the default plot function.
26
27 - If there's a legend, set the background color to 'white' and
28 give it a drop shadow.
29
30 """
31 default_legend_opts = { 'back_color': 'white',
32 'shadow': True }
33
34 # Create an empty plot using the default options.
35 p = Graphics()
36 p.set_legend_options(**default_legend_opts)
37
38 # After trac #12936, this should propagate those options.
39 p += plot_impl(*args, **kwargs)
40 return p
41
42
43 # This way, we don't have to try to replace all of the calls to
44 # plot(); we just replace the one function that did the actual
45 # implementation.
46 sage.plot.plot._plot = mjo_plot