]> gitweb.michael.orlitzky.com - sage.d.git/blob - mjo/plot.py
Fix plot option defaulting.
[sage.d.git] / mjo / plot.py
1 from sage.all import *
2
3 # Save the default so that we can call it within mjo_plot.
4 sage_plot = plot
5
6 def mjo_plot(*args, **kwargs):
7 """
8 Replacement for the default plot function.
9
10 - Use the 'latex' tick formatter.
11
12 - If there's a legend, set the background color to 'white' and
13 give it a drop shadow.
14
15 """
16 plot_opts = { 'tick_formatter': 'latex' }
17
18 # Merge the user's plot options with mine. The ones given as
19 # kwargs should override the defaults!
20 plot_opts.update(kwargs)
21 kwargs = plot_opts
22
23 p = sage_plot(*args, **kwargs)
24
25 # Merge the user's legend options with mine. The ones passed to us
26 # should override the defaults!
27 default_legend_opts = { 'back_color': 'white',
28 'shadow': True }
29 default_legend_opts.update(p._Graphics__legend_opts)
30 p._Graphics__legend_opts = default_legend_opts
31
32 return p
33
34 # Replace both the global `plot` and the ones in the modules. I am
35 # unclear about why this is necessary, and don't care too much.
36 sage.plot.plot.plot = mjo_plot
37 sage.plot.all.plot = mjo_plot
38 plot = mjo_plot