Opened 8 years ago

Closed 8 years ago

#14533 closed enhancement (fixed)

Add strands with different colors in BraidGroup plot

Reported by: mathzeta2 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:

Description (last modified by mathzeta2)

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 mathzeta2 8 years ago.
colored_braid.png (18.6 KB) - added by mathzeta2 8 years ago.
A braid with different colored strands
red_braid.png (12.6 KB) - added by mathzeta2 8 years ago.
A braid with different colored red strands
trac_14533_braid-review-fc.patch (1.9 KB) - added by chapoton 8 years ago.
trac_14533_braid2.patch (1.0 KB) - added by mathzeta2 8 years ago.

Download all attachments as: .zip

Change History (13)

Changed 8 years ago by mathzeta2

Changed 8 years ago by mathzeta2

A braid with different colored strands

Changed 8 years ago by mathzeta2

A braid with different colored red strands

comment:1 Changed 8 years ago by mathzeta2

  • Description modified (diff)

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

  • Reviewers set to Frédéric Chapoton
  • Status changed from new to needs_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 8 years ago by chapoton

comment:3 Changed 8 years ago by chapoton

  • Description modified (diff)

comment:4 Changed 8 years ago by chapoton

  • Description modified (diff)

Changed 8 years ago by mathzeta2

comment:5 Changed 8 years ago by mathzeta2

  • Authors set to Tomer Bauer
  • Description modified (diff)

comment:6 in reply to: ↑ 2 Changed 8 years ago by mathzeta2

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 8 years ago by chapoton

  • Status changed from needs_review to positive_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 8 years ago by jdemeyer

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