]> gitweb.michael.orlitzky.com - sage.d.git/blob - mjo/plot.py
Remove lyapunov_rank() for inclusion in Sage.
[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 list_plot_impl = sage.plot.plot.list_plot
23
24 def mjo_plot(*args, **kwargs):
25 """
26 Replacement for the default plot function.
27
28 - If there's a legend, set the background color to 'white' and
29 give it a drop shadow.
30
31 """
32 default_legend_opts = { 'back_color': 'white',
33 'shadow': True }
34
35 p = plot_impl(*args, **kwargs)
36 p.set_legend_options(**default_legend_opts)
37
38 return p
39
40
41 def mjo_list_plot(*args, **kwargs):
42 """
43 Replacement for the default list_plot function.
44
45 - If there's a legend, set the background color to 'white' and
46 give it a drop shadow.
47
48 """
49 default_legend_opts = { 'back_color': 'white',
50 'shadow': True }
51
52 p = list_plot_impl(*args, **kwargs)
53 p.set_legend_options(**default_legend_opts)
54
55 return p
56
57
58 # This way, we don't have to try to replace all of the calls to plot()
59 # and list_plot(); we just replace the two function that did the
60 # actual implementations.
61 sage.plot.plot._plot = mjo_plot
62 sage.plot.plot.list_plot = mjo_list_plot