Opened 9 years ago

Closed 9 years ago

#14533 closed enhancement (fixed)

Add strands with different colors in BraidGroup plot

Reported by: Tomer Bauer Owned by: joyner
Priority: minor Milestone: sage-5.10
Component: group theory Keywords: braid group, plot
Cc: Merged in: sage-5.10.beta3
Authors: Tomer Bauer Reviewers: Frédéric Chapoton
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description (last modified by Tomer Bauer)

Currently, when plotting a braid, all the strands are in the same color. For plot3d(), even choosing a different color is unavailable.

The attached patch adds the ability to give each strand a different color. This is done for plot() and plot3d().

Few notes:

  • I changed the default coloring scheme, so instead of blue strands, the braids are in different colors.
  • The color option can be one of: single color, which is backwards-compatible; "rainbow", the default; A list or a tuple of colors.
  • Some of the plot options are "global" for the entire plot (e.g. aspect ratio and axes), but some should be "local" for a specific strand (e.g. color, thickness or alpha). Maybe there should be another ticket for this, as I just needed different colored strands.
  • When testing if the color is a list or a tuple I used the idiom isinstance(color, (list, tuple)) which is of prevalent use in Sage. Should we use isinstance(color, collections.Sequence) instead, with the downside that we need to check isinstance(color, types.StringTypes) first?

Two examples:

B6.<a,b,c,d,e> = BraidGroup(6)
z = a^-1*b*c^3*e^-2*a*b^2*a^-3*d^5*c*a*b*c*d*e^2*d^-1*c^-1*b^-1*a^-1
bp1 = z.plot(orientation="left-right")

A braid with different colored strands

from sage.plot import colors
B3.<f,g> = BraidGroup(3)
z2 = g^-1*f^2
bp2 = z2.plot(orientation="top-bottom",
            thickness=4,
            color=[colors.red.lighter(), colors.red, colors.red.darker()])

A braid with different colored red strands

Apply:

Attachments (5)

trac_14533_braid.patch (9.1 KB) - added by Tomer Bauer 9 years ago.
colored_braid.png (18.6 KB) - added by Tomer Bauer 9 years ago.
A braid with different colored strands
red_braid.png (12.6 KB) - added by Tomer Bauer 9 years ago.
A braid with different colored red strands
trac_14533_braid-review-fc.patch (1.9 KB) - added by Frédéric Chapoton 9 years ago.
trac_14533_braid2.patch (1.0 KB) - added by Tomer Bauer 9 years ago.

Download all attachments as: .zip

Change History (13)

Changed 9 years ago by Tomer Bauer

Attachment: trac_14533_braid.patch added

Changed 9 years ago by Tomer Bauer

Attachment: colored_braid.png added

A braid with different colored strands

Changed 9 years ago by Tomer Bauer

Attachment: red_braid.png added

A braid with different colored red strands

comment:1 Changed 9 years ago by Tomer Bauer

Description: modified (diff)

comment:2 Changed 9 years ago by Frédéric Chapoton

Reviewers: Frédéric Chapoton
Status: newneeds_review

looks good to me. If you are happy with my review (add test and removes some unused imports) then you can set a positive review

Changed 9 years ago by Frédéric Chapoton

comment:3 Changed 9 years ago by Frédéric Chapoton

Description: modified (diff)

comment:4 Changed 9 years ago by Frédéric Chapoton

Description: modified (diff)

Changed 9 years ago by Tomer Bauer

Attachment: trac_14533_braid2.patch added

comment:5 Changed 9 years ago by Tomer Bauer

Authors: Tomer Bauer
Description: modified (diff)

comment:6 in reply to:  2 Changed 9 years ago by Tomer Bauer

Replying to chapoton:

looks good to me. If you are happy with my review (add test and removes some unused imports) then you can set a positive review

Thanks for your review. I had a trivial whitespace nitpick I added in trac_14533_braid2.patch. I think it's OK now.

This is new to me; Who should set the review status now?

comment:7 Changed 9 years ago by Frédéric Chapoton

Status: needs_reviewpositive_review

well, there is no rule, as far as I know, but maybe not the author of the "latest patch"..

Anyway, looks good to me, positive review !

comment:8 Changed 9 years ago by Jeroen Demeyer

Merged in: sage-5.10.beta3
Resolution: fixed
Status: positive_reviewclosed
Note: See TracTickets for help on using tickets.