# HG changeset patch
# User Michael Orlitzky <michael@orlitzky.com>
# Date 1336700132 14400
# Node ID a4e9c32259bd7f42c4f066a8dd5185819d824fc3
# Parent 9e488f0b4280c1bb10e5c2b08a797181d42de37a
Trac #12936: Preserve legend options when adding plots.
diff --git a/sage/plot/graphics.py b/sage/plot/graphics.py
a
|
b
|
|
961 | 961 | aspect ratio is chosen, with 'automatic' being overridden by a |
962 | 962 | numeric aspect ratio. |
963 | 963 | |
964 | | If one of the graphics object is set to show a legend, then the |
965 | | resulting object will also be set to show a legend. None of the |
966 | | legend options are carried over. |
| 964 | If one of the graphics object is set to show a legend, then |
| 965 | the resulting object will also be set to show a legend. Legend |
| 966 | options are propagated if set. If the same legend option is |
| 967 | present in both arguments, the latter value is used. |
967 | 968 | |
968 | 969 | EXAMPLES:: |
969 | 970 | |
… |
… |
|
983 | 984 | sage: g2.set_aspect_ratio(3) |
984 | 985 | sage: (g1+g2).aspect_ratio() |
985 | 986 | 3.0 |
| 987 | |
| 988 | As are legend options, :trac:`12936`:: |
| 989 | |
| 990 | sage: p1 = plot(x, x, 0, 1) |
| 991 | sage: p2 = p1 |
| 992 | sage: p1.set_legend_options(back_color = 'white') |
| 993 | sage: p2.set_legend_options(shadow = True) |
| 994 | sage: p3 = p1 + p2 |
| 995 | sage: p3._Graphics__legend_opts |
| 996 | {'shadow': True, 'back_color': 'white'} |
| 997 | |
| 998 | If the same legend option is specified more than once, the |
| 999 | latter takes precedence:: |
| 1000 | |
| 1001 | sage: p1 = plot(x, x, 0, 1) |
| 1002 | sage: p2 = p1 |
| 1003 | sage: p1.set_legend_options(shadow = True) |
| 1004 | sage: p2.set_legend_options(shadow = False) |
| 1005 | sage: p3 = p1 + p2 |
| 1006 | sage: p3._Graphics__legend_opts |
| 1007 | {'shadow': False} |
| 1008 | |
986 | 1009 | """ |
987 | 1010 | if isinstance(other, int) and other == 0: |
988 | 1011 | return self |
… |
… |
|
996 | 1019 | g.__show_legend = self.__show_legend or other.__show_legend |
997 | 1020 | g._extra_kwds.update(self._extra_kwds) |
998 | 1021 | g._extra_kwds.update(other._extra_kwds) |
| 1022 | g._Graphics__legend_opts.update(self._Graphics__legend_opts) |
| 1023 | g._Graphics__legend_opts.update(other._Graphics__legend_opts) |
999 | 1024 | if self.aspect_ratio()=='automatic': |
1000 | 1025 | g.set_aspect_ratio(other.aspect_ratio()) |
1001 | 1026 | elif other.aspect_ratio()=='automatic': |