Opened 8 years ago
Closed 8 years ago
#13690 closed defect (fixed)
legend marker 'o' is incorrectly printed
Reported by: | ppurka | Owned by: | jason, was |
---|---|---|---|
Priority: | major | Milestone: | sage-5.10 |
Component: | graphics | Keywords: | |
Cc: | Merged in: | sage-5.10.rc0 | |
Authors: | Punarbasu Purkayastha | Reviewers: | Nathann Cohen |
Report Upstream: | N/A | Work issues: | |
Branch: | Commit: | ||
Dependencies: | #13693 | Stopgaps: |
Description (last modified by )
Just look at the output of this command
list_plot(range(3), plotjoined=True, marker='o', legend_label='square here, circle there')
The marker in the legend should be a o
but it is actually printed as a square. This seems to be a bug in Sage because I couldn't reproduce it in matplotlib. I tried the following two variants:
import matplotlib.pyplot as plt plt.plot(range(3), range(3), '-o') plt.legend('square here') plt.savefig('a.png')
import matplotlib.lines as lines from matplotlib.figure import Figure options = {'marker': 'o'} p = lines.Line2D(range(3), range(3), **options) p.set_label('square here, circle there') figure=Figure() subplot = figure.add_subplot(111) subplot.add_line(p) subplot.legend() from matplotlib.backends.backend_agg import FigureCanvasAgg figure.set_canvas(FigureCanvasAgg(figure)) figure.savefig('a.png')
The bug dates back to at least sage-4.7. That's the oldest precompiled version of sage I had around here.
Attached patch contains a test to the line()
function.
Apply trac_13690-legend_test_for_line.patch to devel/sage
.
Attachments (1)
Change History (16)
comment:1 Changed 8 years ago by
- Description modified (diff)
comment:2 follow-up: ↓ 4 Changed 8 years ago by
comment:3 follow-up: ↓ 6 Changed 8 years ago by
I just tried this on my local computer with #13693 applied and the legend showed up correctly. Can someone double-check that the upgrade to matplotlib 1.2.0 fixes this problem?
comment:4 in reply to: ↑ 2 Changed 8 years ago by
Replying to jason:
And it's not just list_plot. Here is an example with line:
line(enumerate([1,2,1]), marker = 'o', legend_label='a')
My second matplotlib example essentially does whatever the line
command does. Also plotjoined=True
in list_plot
calls line
directly.
comment:5 Changed 8 years ago by
Right. Thanks.
comment:6 in reply to: ↑ 3 Changed 8 years ago by
- Dependencies set to #13693
Replying to jason:
I just tried this on my local computer with #13693 applied and the legend showed up correctly. Can someone double-check that the upgrade to matplotlib 1.2.0 fixes this problem?
Yes. Upgrade to mpl-1.2.0 fixes this. I am flummoxed.
Setting dependency to #13693 since fixing that will fix this automatically.
comment:7 Changed 8 years ago by
And I am relieved! We won't have to track this down.
comment:8 Changed 8 years ago by
I am relieved too! This is a nasty bug; very unreproducible.
comment:9 follow-up: ↓ 10 Changed 8 years ago by
I assume we should put something in a TESTS
block somewhere then for this ticket? In the sense that we could ask someone to visually confirm the output, not that we are actually comparing images.
comment:10 in reply to: ↑ 9 Changed 8 years ago by
- Description modified (diff)
Replying to kcrisman:
I assume we should put something in a
TESTS
block somewhere then for this ticket? In the sense that we could ask someone to visually confirm the output, not that we are actually comparing images.
You are right. I attached a patch.
comment:11 Changed 8 years ago by
#13693 is in. I just kicked the patchbot. Let's see if the patch still applies.
comment:12 Changed 8 years ago by
- Status changed from new to needs_review
comment:13 Changed 8 years ago by
- Reviewers set to Nathann Cohen
- Status changed from needs_review to positive_review
Just a doctest, it cannot hurt :-)
Nathann
comment:14 Changed 8 years ago by
Thanks :)
comment:15 Changed 8 years ago by
- Merged in set to sage-5.10.rc0
- Resolution set to fixed
- Status changed from positive_review to closed
And it's not just list_plot. Here is an example with line: