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 ppurka)

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)

trac_13690-legend_test_for_line.patch (765 bytes) - added by ppurka 8 years ago.
Apply to devel/sage

Download all attachments as: .zip

Change History (16)

comment:1 Changed 8 years ago by ppurka

  • Description modified (diff)

comment:2 follow-up: Changed 8 years ago by jason

And it's not just list_plot. Here is an example with line:

line(enumerate([1,2,1]), marker = 'o', legend_label='a')

comment:3 follow-up: Changed 8 years ago by 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?

comment:4 in reply to: ↑ 2 Changed 8 years ago by ppurka

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 jason

Right. Thanks.

comment:6 in reply to: ↑ 3 Changed 8 years ago by ppurka

  • 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 jason

And I am relieved! We won't have to track this down.

comment:8 Changed 8 years ago by ppurka

I am relieved too! This is a nasty bug; very unreproducible.

comment:9 follow-up: Changed 8 years ago by 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.

Changed 8 years ago by ppurka

Apply to devel/sage

comment:10 in reply to: ↑ 9 Changed 8 years ago by ppurka

  • 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 ppurka

#13693 is in. I just kicked the patchbot. Let's see if the patch still applies.

comment:12 Changed 8 years ago by ppurka

  • Status changed from new to needs_review

comment:13 Changed 8 years ago by ncohen

  • Authors set to Punarbasu Purkayastha
  • 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 ppurka

Thanks :)

comment:15 Changed 8 years ago by jdemeyer

  • Merged in set to sage-5.10.rc0
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.