Ticket #10512 (closed enhancement: fixed)
wrap matplotlib's title functionality
| Reported by: | jason | Owned by: | jason |
|---|---|---|---|
| Priority: | major | Milestone: | sage-5.3 |
| Component: | graphics | Keywords: | |
| Cc: | kcrisman, slabbe | Work issues: | |
| Report Upstream: | N/A | Reviewers: | Sébastien Labbé, Punarbasu Purkayastha |
| Authors: | Jason Grout, Punarbasu Purkayastha, Sébastien Labbé | Merged in: | sage-5.3.beta2 |
| Dependencies: | Stopgaps: |
Description (last modified by slabbe) (diff)
We should wrap matplotlib's ability to add titles to axes, perhaps as an option to show.
http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.title
http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.suptitle
Apply trac-10512-plot-title.1.patch and trac_10512_review-sl.patch to devel/sage
Attachments
Change History
comment:2 follow-ups: ↓ 4 ↓ 13 Changed 2 years ago by jason
- Owner changed from jason, was to jason
I've attached a patch. There is still an issue that needs to be solved, though. In this plot:
plot(sin(x^2), (x, -3, 3), title='Plot of sin(x)', axes_labels=['x','y'],frame=True)
the title overwrites the axis label. Maybe the axis label should be smarter here, or the plot title should be slightly adjusted up in this situation.
comment:4 in reply to: ↑ 2 Changed 2 years ago by slabbe
plot(sin(x^2), (x, -3, 3), title='Plot of sin(x)', axes_labels=['x','y'],frame=True)
I get no problem when frame=True but do get the described problem when frame=False.
Sébastien
comment:5 Changed 10 months ago by ppurka
- Status changed from needs_work to needs_review
- Description modified (diff)
- Authors set to Jason Grout
Updated the patch to sage-5.2 and fixed the positioning of the title. Please review.
Changed 10 months ago by ppurka
-
attachment
trac-10512-plot-title.1.patch
added
updated to sage-5.2, fixed position
comment:6 Changed 10 months ago by ppurka
There was a small typo in the backticks used around the title docstring. Fixed it now.
Changed 10 months ago by slabbe
-
attachment
trac_10512_review-sl.patch
added
Applies over the preceding patche
comment:7 Changed 10 months ago by slabbe
I added a patch which adds a doctest about the fact that
plot(sin(x^2), (x, -3, 3), title='Plot of sin(x^2)', axes_labels=['x','y'],frame=True)
should be ok (no overlap between title and axes labels). I know the doctest system won't see in the future if it is not the case, but at least the documentation will recall it.
Also added some x^2 in title instead of x.
My patch needs review.
I tested ppurka patch. All tests passed on sage/combinat/graphics.py and plot.py. Documentation builds fine. I give a positive review to his patch.
BTW I am wondering why ppurka started from scratch instead of applying a patch over jason's one? Jason work will not appear in the log...
comment:9 Changed 10 months ago by ppurka
Hello, the patch still contains Jason's name in the patch header. The patch fails in many places in 5.2, and I had to move many of the patch lines from plot.py to graphics.py. Otherwise the code is almost the same as what Jason had.
comment:10 Changed 9 months ago by ppurka
- Status changed from needs_review to positive_review
- Reviewers set to Sebastien Labbe, Punarbasu Purkayastha
- Authors changed from Jason Grout to Jason Grout, Punarbasu Purkayastha, Sebastien Labbe
Thanks for the patch. That was a good catch on the typos. :) Positive review from me.
I see now what you actually meant in comment:7. I am setting the authors as all three of us. That should be good enough.
comment:11 Changed 9 months ago by jdemeyer
- Status changed from positive_review to closed
- Resolution set to fixed
- Merged in set to sage-5.3.beta2
comment:12 Changed 9 months ago by jdemeyer
- Reviewers changed from Sebastien Labbe, Punarbasu Purkayastha to Sébastien Labbé, Punarbasu Purkayastha
- Authors changed from Jason Grout, Punarbasu Purkayastha, Sebastien Labbe to Jason Grout, Punarbasu Purkayastha, Sébastien Labbé
comment:13 in reply to: ↑ 2 Changed 7 months ago by kcrisman
Replying to jason:
I've attached a patch. There is still an issue that needs to be solved, though. In this plot:
plot(sin(x^2), (x, -3, 3), title='Plot of sin(x)', axes_labels=['x','y'],frame=True)the title overwrites the axis label. Maybe the axis label should be smarter here, or the plot title should be slightly adjusted up in this situation.
It turns out that this happens in matrix plots as well, even with this code (because it has a frame). See this ask.sagemath.org question. I've opened #13625 for this.
