Ticket #8529 (closed defect: fixed)
default colors for plot and implicit_plot are not consistent
| Reported by: | AlexGhitza | Owned by: | was |
|---|---|---|---|
| Priority: | minor | Milestone: | sage-4.6.1 |
| Component: | graphics | Keywords: | plot default color beginner |
| Cc: | kcrisman | Work issues: | |
| Report Upstream: | N/A | Reviewers: | Jason Grout, Karl-Dieter Crisman |
| Authors: | Ryan Grout | Merged in: | sage-4.6.1.alpha0 |
| Dependencies: | Stopgaps: |
Description
When plotting a function using plot, the default color for the graph of the function is blue. The default color for implicit_plot is black. It would be preferable to have the same default color.
Attachments
Change History
comment:3 Changed 3 years ago by ryan
the attached patch will change the default color of plot to black (so that it matches implicit_plot).
comment:4 follow-up: ↓ 9 Changed 3 years ago by jason
- Status changed from new to needs_work
Ryan! Welcome to Trac! Congratulations on your patch!
I think maybe it would be better to make the implicit plot default color be blue. I like that a plot is a different color than the axes so that it's easier to distinguish the two.
Also, when a patch is ready for review, change the state below to "needs review".
comment:5 follow-up: ↓ 8 Changed 3 years ago by jason
See http://sagenb.org/home/jason3/230/ for how to plot implicit plots in a different color:
var('x,y')
implicit_plot(x^2-y^2==1, (x,-5,5), (y,-5,5), cmap=["red"])
I think it might be enough to give another argument to the @options decorator for implicit_plot: cmap=["blue"]
comment:6 follow-up: ↓ 7 Changed 3 years ago by jason
Even better, do cmap=("blue"), since then the tuple can not be modified by other things.
comment:7 in reply to: ↑ 6 Changed 3 years ago by jason
Replying to jason:
Even better, do cmap=("blue"), since then the tuple can not be modified by other things.
I mean cmap=("blue",), so that it's a tuple, not just a string in parentheses.
comment:8 in reply to: ↑ 5 ; follow-up: ↓ 10 Changed 3 years ago by kcrisman
Replying to jason:
See http://sagenb.org/home/jason3/230/ for how to plot implicit plots in a different color:
If you published this, you didn't include the link.
var('x,y')
implicit_plot(x^2-y^2==1, (x,-5,5), (y,-5,5), cmap=["red"])
So annoying that color='red' wouldn't work. What happens with that?
comment:9 in reply to: ↑ 4 Changed 3 years ago by kcrisman
Replying to jason:
Ryan! Welcome to Trac! Congratulations on your patch!
Yes! You aren't by chance the famed little brother of Jason, are you?
comment:10 in reply to: ↑ 8 Changed 3 years ago by jason
Replying to kcrisman:
So annoying that color='red' wouldn't work. What happens with that?
That would take one or two more lines of code to support. Probably add it to @options, and then make a cmap=[<color>] argument that is passed to contour_plot.
comment:11 Changed 3 years ago by ryan
ok...here's the new patch.
One can now set the color of implicit_plot using cmap or the "new" color option (idea curtesy of kcrisman). Note: syntax for cmap is still the same. Syntax for color is color='blue'
@kcrisman: Yeah, I'm Jason's little brother.
Have fun with all those colorful plots :)
comment:12 Changed 3 years ago by jason
This is great. Just one more thing: there should be some sort of doctest illustrating this (the question of how to change the color of an implicit plot has come up before, and it's bound to come up again, so it'd be nice to just point them to the documentation of the function).
Just take your favorite example and put it in the EXAMPLES section of the docstring of the function, following the format of the examples around it.
comment:13 Changed 3 years ago by jason
(and it's more than nice; patches are required to have doctests if they fix a bug or add new features these days...)
After you add a doctest, then you can run:
sage -b
to rebuild, and then
sage -t contour_plot.py
to run the tests.
Changed 3 years ago by ryan
-
attachment
trac_8529_color_implicit_plot.patch
added
(Patch + Documentation) Change color of implicit plot.
comment:14 Changed 3 years ago by ryan
ok...updated patch (with documentation).
Thanks jason for the reminder add the documentation. This patch passed the doctests.
comment:16 Changed 3 years ago by kcrisman
- Status changed from needs_review to positive_review
- Reviewers set to Jason Grout, Karl-Dieter Crisman
- Authors set to Ryan Grout
This is nice - positive review.
I fixed some minor doc issues added a really cool example I stumbled upon while testing it (picture attached), and also updated some other minor doc issues which became apparent with this - all of which are basically related to the color or are just typos.
To release manager: Apply trac_8529-color-implicit-plot and then trac-8529-reviewer.
Changed 3 years ago by kcrisman
-
attachment
ColorfulCircles.png
added
Super-cool example picture of this patch working
comment:17 Changed 3 years ago by jason
This solves #9654 too.
comment:18 follow-up: ↓ 19 Changed 3 years ago by jason
please apply my reviewer-reviewer patch on top of everything else; it simplifies the doc source a little.
comment:19 in reply to: ↑ 18 Changed 3 years ago by kcrisman
Replying to jason:
please apply my reviewer-reviewer patch on top of everything else; it simplifies the doc source a little.
Thanks, I didn't know about this ~ notation.
comment:20 Changed 3 years ago by kcrisman
Just FYI, the (essentially) positively reviewed #9203 and #9076 add functions with the same ~ not being used, and won't apply properly with this one. I recommend that those be applied first, then this one applied to see what would need to be updated, and then this one updated - since those implement actual new functionality. Or we can split this one up into a different ticket for updating the plot doc, or add that in with #9746.
comment:21 Changed 3 years ago by mpatel
- Status changed from positive_review to needs_work
- Work issues set to rebase
With the other tickets merged into 4.6.alpha1, I get
[...] $ hg qpush applying trac-8529-reviewer-reviewer.patch patching file sage/plot/plot.py Hunk #1 FAILED at 6 1 out of 3 hunks FAILED -- saving rejects to file sage/plot/plot.py.rej patch failed, unable to continue (try -v) patch failed, rejects left in working dir errors during apply, please fix and refresh trac-8529-reviewer-reviewer.patch
The .rej file:
-
plot.py
7 7 The following graphics primitives are supported: 8 8 9 9 10 - :func:` arrow() <sage.plot.arrow.arrow>` - an arrow from a min point to a max point.11 12 - :func:` circle() <sage.plot.circle.circle>` - a circle with given radius13 14 - :func:` disk() <sage.plot.disk.disk>` - a filled disk (i.e. a sector or wedge of a circle)15 16 - :func:` line() <sage.plot.line.line>` - a line determined by a sequence of points (this need not10 - :func:`~sage.plot.arrow.arrow` - an arrow from a min point to a max point. 11 12 - :func:`~sage.plot.circle.circle` - a circle with given radius 13 14 - :func:`~sage.plot.disk.disk` - a filled disk (i.e. a sector or wedge of a circle) 15 16 - :func:`~sage.plot.line.line` - a line determined by a sequence of points (this need not 17 17 be straight!) 18 18 19 - :func:` point() <sage.plot.point.point>` - a point20 21 - :func:` text() <sage.plot.text.text>` - some text22 23 - :func:` polygon() <sage.plot.polygon.polygon>` - a filled polygon19 - :func:`~sage.plot.point.point` - a point 20 21 - :func:`~sage.plot.text.text` - some text 22 23 - :func:`~sage.plot.polygon.polygon` - a filled polygon 24 24 25 25 26 26 The following plotting functions are supported:
Could someone rebase the "reviewer-reviewer" patch when 4.6.alpha1 is out?
Changed 3 years ago by jason
-
attachment
trac-8529-reviewer-reviewer.patch
added
apply on top of previous patches
comment:22 Changed 3 years ago by jason
- Status changed from needs_work to positive_review
I rebased the reviewer-reviewer patch for 4.6.alpha3. In fact, that reviewer-reviewer patch was so picky, it probably would have been okay to just ignore it anyway.
comment:23 Changed 3 years ago by jdemeyer
- Status changed from positive_review to closed
- Resolution set to fixed
- Work issues rebase deleted
- Merged in set to sage-4.6.1.alpha0
