From 47c19bb2099678874e6a7a2f8a7d2599ce676c73 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Fri, 31 May 2024 12:38:22 +0100 Subject: [PATCH 01/11] Added example in documentation of set_legends_options --- src/sage/plot/graphics.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/sage/plot/graphics.py b/src/sage/plot/graphics.py index a5e46d07c2d..797fd498f25 100644 --- a/src/sage/plot/graphics.py +++ b/src/sage/plot/graphics.py @@ -310,7 +310,7 @@ def legend(self, show=None): False sage: P.legend(True) sage: P # show with the legend - Graphics object consisting of 1 graphics primitive + Graphics object consisting of 1 graphics primitive """ if show is None: return self._show_legend @@ -430,6 +430,19 @@ def set_legend_options(self, **kwds): sage: p.set_legend_options(loc=(0.5,0.5)); p # aligns the bottom of the box to the center # needs sage.symbolic Graphics object consisting of 1 graphics primitive + + The dictionary ``_extra_kwds`` stores the keywords for graphics. This can be used to adjust vertical or + horizonal displacements from the x-axis or y-axis respectively:: + + sage: p = line([(0, 0), (1, 1)], legend_label='test', axes_labels=('X LABEL', 'Y LABEL')) + sage: labels = p._extra_kwds.get('axes_labels') + sage: if labels and labels[0]: + ....: displace = -.14 - .005 * p.fontsize() + ....: else: + ....: displace = -.14 + ....: p.set_legend_options(bbox_to_anchor=(0., displace, 1., .102), loc=3, mode="expand", borderaxespad=0.) + sage: print(p) + Graphics object consisting of 1 graphics primitive """ if len(kwds) == 0: return self._legend_opts From cdc16e878f6ab0e4239a9a1d58c2dd1ca0e42e51 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Tue, 4 Jun 2024 13:37:36 +0100 Subject: [PATCH 02/11] Edited last example of set_legend_options --- src/sage/plot/graphics.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/sage/plot/graphics.py b/src/sage/plot/graphics.py index 797fd498f25..4e8b4cf1140 100644 --- a/src/sage/plot/graphics.py +++ b/src/sage/plot/graphics.py @@ -431,16 +431,12 @@ def set_legend_options(self, **kwds): sage: p.set_legend_options(loc=(0.5,0.5)); p # aligns the bottom of the box to the center # needs sage.symbolic Graphics object consisting of 1 graphics primitive - The dictionary ``_extra_kwds`` stores the keywords for graphics. This can be used to adjust vertical or - horizonal displacements from the x-axis or y-axis respectively:: + The parameters ``loc`` and ``borderaxespad`` can be altered in order to place the legend below the x-axis label or to the left of the y-axis label. + The following example sets ``loc=3`` and ``borderaxespad = ``-7.5-0.01*p.fontsize()`` so as to obtain the legend below the x-axis label. sage: p = line([(0, 0), (1, 1)], legend_label='test', axes_labels=('X LABEL', 'Y LABEL')) - sage: labels = p._extra_kwds.get('axes_labels') - sage: if labels and labels[0]: - ....: displace = -.14 - .005 * p.fontsize() - ....: else: - ....: displace = -.14 - ....: p.set_legend_options(bbox_to_anchor=(0., displace, 1., .102), loc=3, mode="expand", borderaxespad=0.) + sage: p.axes_labels(['X-Label', 'Y-Label']) + sage: p.set_legend_options(loc=8, borderaxespad=-7.5-0.01*p.fontsize()) sage: print(p) Graphics object consisting of 1 graphics primitive """ From 5e7ece9479713d30e52afcdad6a53da6796e6dcc Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Tue, 4 Jun 2024 15:28:06 +0100 Subject: [PATCH 03/11] Added comments --- src/sage/plot/graphics.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/plot/graphics.py b/src/sage/plot/graphics.py index 4e8b4cf1140..0f6d0b686b8 100644 --- a/src/sage/plot/graphics.py +++ b/src/sage/plot/graphics.py @@ -435,7 +435,7 @@ def set_legend_options(self, **kwds): The following example sets ``loc=3`` and ``borderaxespad = ``-7.5-0.01*p.fontsize()`` so as to obtain the legend below the x-axis label. sage: p = line([(0, 0), (1, 1)], legend_label='test', axes_labels=('X LABEL', 'Y LABEL')) - sage: p.axes_labels(['X-Label', 'Y-Label']) + sage: p.axes_labels(['X-Label', 'Y-Label']) # adding labels for axes sage: p.set_legend_options(loc=8, borderaxespad=-7.5-0.01*p.fontsize()) sage: print(p) Graphics object consisting of 1 graphics primitive From 671d26828431c3af889e04fea1b343ce3538839d Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Tue, 4 Jun 2024 15:41:12 +0100 Subject: [PATCH 04/11] Corrected line() method --- src/sage/plot/graphics.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/plot/graphics.py b/src/sage/plot/graphics.py index 0f6d0b686b8..382b8046d1c 100644 --- a/src/sage/plot/graphics.py +++ b/src/sage/plot/graphics.py @@ -434,7 +434,7 @@ def set_legend_options(self, **kwds): The parameters ``loc`` and ``borderaxespad`` can be altered in order to place the legend below the x-axis label or to the left of the y-axis label. The following example sets ``loc=3`` and ``borderaxespad = ``-7.5-0.01*p.fontsize()`` so as to obtain the legend below the x-axis label. - sage: p = line([(0, 0), (1, 1)], legend_label='test', axes_labels=('X LABEL', 'Y LABEL')) + sage: p = line([(0, 0), (1, 1)], legend_label='test') sage: p.axes_labels(['X-Label', 'Y-Label']) # adding labels for axes sage: p.set_legend_options(loc=8, borderaxespad=-7.5-0.01*p.fontsize()) sage: print(p) From c46b63023bb7a9ef1ad991e2c39cde1a29f6fee7 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Tue, 4 Jun 2024 15:51:55 +0100 Subject: [PATCH 05/11] Solved first set of linting errors --- src/sage/plot/graphics.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sage/plot/graphics.py b/src/sage/plot/graphics.py index 382b8046d1c..a6648405d8e 100644 --- a/src/sage/plot/graphics.py +++ b/src/sage/plot/graphics.py @@ -309,7 +309,7 @@ def legend(self, show=None): sage: P.legend() False sage: P.legend(True) - sage: P # show with the legend + sage: P # show with the legend Graphics object consisting of 1 graphics primitive """ if show is None: @@ -428,11 +428,11 @@ def set_legend_options(self, **kwds): :: - sage: p.set_legend_options(loc=(0.5,0.5)); p # aligns the bottom of the box to the center # needs sage.symbolic + sage: p.set_legend_options(loc=(0.5,0.5)); p # aligns the bottom of the box to the center # needs sage.symbolic Graphics object consisting of 1 graphics primitive The parameters ``loc`` and ``borderaxespad`` can be altered in order to place the legend below the x-axis label or to the left of the y-axis label. - The following example sets ``loc=3`` and ``borderaxespad = ``-7.5-0.01*p.fontsize()`` so as to obtain the legend below the x-axis label. + The following example sets ``loc=3`` and ``borderaxespad = -7.5-0.01*p.fontsize()`` so as to obtain the legend below the x-axis label. sage: p = line([(0, 0), (1, 1)], legend_label='test') sage: p.axes_labels(['X-Label', 'Y-Label']) # adding labels for axes From 9f3627e71c0820dafad9026729591370b93415ca Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Wed, 5 Jun 2024 12:44:28 +0100 Subject: [PATCH 06/11] Solved second set of linting errors --- src/sage/plot/graphics.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sage/plot/graphics.py b/src/sage/plot/graphics.py index a6648405d8e..c6fc065edcd 100644 --- a/src/sage/plot/graphics.py +++ b/src/sage/plot/graphics.py @@ -310,7 +310,7 @@ def legend(self, show=None): False sage: P.legend(True) sage: P # show with the legend - Graphics object consisting of 1 graphics primitive + Graphics object consisting of 1 graphics primitive """ if show is None: return self._show_legend @@ -430,10 +430,10 @@ def set_legend_options(self, **kwds): sage: p.set_legend_options(loc=(0.5,0.5)); p # aligns the bottom of the box to the center # needs sage.symbolic Graphics object consisting of 1 graphics primitive - + The parameters ``loc`` and ``borderaxespad`` can be altered in order to place the legend below the x-axis label or to the left of the y-axis label. The following example sets ``loc=3`` and ``borderaxespad = -7.5-0.01*p.fontsize()`` so as to obtain the legend below the x-axis label. - + sage: p = line([(0, 0), (1, 1)], legend_label='test') sage: p.axes_labels(['X-Label', 'Y-Label']) # adding labels for axes sage: p.set_legend_options(loc=8, borderaxespad=-7.5-0.01*p.fontsize()) From 116181336d8ee8990a7dfb4f121879403431d54c Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Wed, 5 Jun 2024 12:56:20 +0100 Subject: [PATCH 07/11] Solved third set of linting errors --- src/sage/plot/graphics.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/plot/graphics.py b/src/sage/plot/graphics.py index c6fc065edcd..e9e7e74abda 100644 --- a/src/sage/plot/graphics.py +++ b/src/sage/plot/graphics.py @@ -310,7 +310,7 @@ def legend(self, show=None): False sage: P.legend(True) sage: P # show with the legend - Graphics object consisting of 1 graphics primitive + Graphics object consisting of 1 graphics primitive """ if show is None: return self._show_legend From 7a758d01d90805eb6e0d9adb31766df9bdba9355 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Wed, 5 Jun 2024 14:38:37 +0100 Subject: [PATCH 08/11] Edited Documentation --- src/sage/plot/graphics.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/plot/graphics.py b/src/sage/plot/graphics.py index e9e7e74abda..b247dd47fb3 100644 --- a/src/sage/plot/graphics.py +++ b/src/sage/plot/graphics.py @@ -432,7 +432,7 @@ def set_legend_options(self, **kwds): Graphics object consisting of 1 graphics primitive The parameters ``loc`` and ``borderaxespad`` can be altered in order to place the legend below the x-axis label or to the left of the y-axis label. - The following example sets ``loc=3`` and ``borderaxespad = -7.5-0.01*p.fontsize()`` so as to obtain the legend below the x-axis label. + The following example sets ``loc=3`` and ``borderaxespad = -7.5-0.01*p.fontsize()`` so as to obtain the legend below the x-axis label:: sage: p = line([(0, 0), (1, 1)], legend_label='test') sage: p.axes_labels(['X-Label', 'Y-Label']) # adding labels for axes From c8e850a8f80f1f46fef5772a014c16a1feaee067 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Thu, 6 Jun 2024 09:52:29 +0100 Subject: [PATCH 09/11] Edited Documentation --- src/sage/plot/graphics.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/plot/graphics.py b/src/sage/plot/graphics.py index b247dd47fb3..e9e7e74abda 100644 --- a/src/sage/plot/graphics.py +++ b/src/sage/plot/graphics.py @@ -432,7 +432,7 @@ def set_legend_options(self, **kwds): Graphics object consisting of 1 graphics primitive The parameters ``loc`` and ``borderaxespad`` can be altered in order to place the legend below the x-axis label or to the left of the y-axis label. - The following example sets ``loc=3`` and ``borderaxespad = -7.5-0.01*p.fontsize()`` so as to obtain the legend below the x-axis label:: + The following example sets ``loc=3`` and ``borderaxespad = -7.5-0.01*p.fontsize()`` so as to obtain the legend below the x-axis label. sage: p = line([(0, 0), (1, 1)], legend_label='test') sage: p.axes_labels(['X-Label', 'Y-Label']) # adding labels for axes From 6f4e333c9e23a0bcdf34033bdd8ffb782e1ae73f Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Thu, 6 Jun 2024 11:16:50 +0100 Subject: [PATCH 10/11] Edited Documentation --- src/sage/plot/graphics.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/plot/graphics.py b/src/sage/plot/graphics.py index e9e7e74abda..b247dd47fb3 100644 --- a/src/sage/plot/graphics.py +++ b/src/sage/plot/graphics.py @@ -432,7 +432,7 @@ def set_legend_options(self, **kwds): Graphics object consisting of 1 graphics primitive The parameters ``loc`` and ``borderaxespad`` can be altered in order to place the legend below the x-axis label or to the left of the y-axis label. - The following example sets ``loc=3`` and ``borderaxespad = -7.5-0.01*p.fontsize()`` so as to obtain the legend below the x-axis label. + The following example sets ``loc=3`` and ``borderaxespad = -7.5-0.01*p.fontsize()`` so as to obtain the legend below the x-axis label:: sage: p = line([(0, 0), (1, 1)], legend_label='test') sage: p.axes_labels(['X-Label', 'Y-Label']) # adding labels for axes From 9c49a296950c4c54f6b5cbf5f5b97feca9c9d536 Mon Sep 17 00:00:00 2001 From: Shriya M <25shriya@gmail.com> Date: Mon, 10 Jun 2024 20:02:33 +0100 Subject: [PATCH 11/11] Formatted Documentation --- src/sage/plot/graphics.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/sage/plot/graphics.py b/src/sage/plot/graphics.py index b247dd47fb3..0d96d3d6150 100644 --- a/src/sage/plot/graphics.py +++ b/src/sage/plot/graphics.py @@ -431,13 +431,14 @@ def set_legend_options(self, **kwds): sage: p.set_legend_options(loc=(0.5,0.5)); p # aligns the bottom of the box to the center # needs sage.symbolic Graphics object consisting of 1 graphics primitive - The parameters ``loc`` and ``borderaxespad`` can be altered in order to place the legend below the x-axis label or to the left of the y-axis label. - The following example sets ``loc=3`` and ``borderaxespad = -7.5-0.01*p.fontsize()`` so as to obtain the legend below the x-axis label:: + The parameters ``loc`` and ``borderaxespad`` can be altered + in order to place the legend below the x-axis label or to + the left of the y-axis label:: sage: p = line([(0, 0), (1, 1)], legend_label='test') - sage: p.axes_labels(['X-Label', 'Y-Label']) # adding labels for axes + sage: p.axes_labels(['X-Label', 'Y-Label']) # adding labels for axes sage: p.set_legend_options(loc=8, borderaxespad=-7.5-0.01*p.fontsize()) - sage: print(p) + sage: p Graphics object consisting of 1 graphics primitive """ if len(kwds) == 0: