]> gitweb.michael.orlitzky.com - sage.d.git/blob - mjo/plot.py
Initial commit.
[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 legend_opts = { 'back_color': 'white',
19 'shadow': True }
20
21 # Merge the user's plot options with mine. The ones given as
22 # kwargs should override the defaults!
23 plot_opts.update(kwargs)
24 kwargs = plot_opts
25 p = sage_plot(*args, **kwargs)
26 p.set_legend_options(**legend_opts)
27 return p
28
29 # Replace both the global `plot` and the one in the module. I am
30 # unclear about why this is necessary, and don't care too much.
31 sage.plot.plot.plot = mjo_plot
32 plot = mjo_plot