Opened 9 years ago

Closed 9 years ago

#6615 closed defect (fixed)

Small bug in Graph.plot()

Reported by: ncohen Owned by: rlm
Priority: major Milestone: sage-4.3.1
Component: graph theory Keywords:
Cc: Merged in: sage-4.3.1.alpha2
Authors: Nathann Cohen Reviewers: Robert Miller
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Description (last modified by ncohen)

It may take only two lines, but I do not know which ones (I got a bit lost reading graph_plot.py) and it may take half a second to who wrote it in the first place.

g=graphs.PetersenGraph?()

g.plot(edge_colors={"red":[(0,1)]})

g.plot(vertex_colors={"red":[1]})

When you plot a graph and want some edges to have a different color, the first plot is perfect. In the second case, though, I think it would be better to assign the others vertices a default color ;-)

Attachments (1)

trac_6615-ref.patch (3.5 KB) - added by rlm 9 years ago.
depends: sage-4.3.1.alpha1 + #7634

Download all attachments as: .zip

Change History (14)

comment:1 Changed 9 years ago by ncohen

  • Description modified (diff)

comment:2 follow-up: Changed 9 years ago by ncohen

The best way to do that may be to let vertex_colors (resp. edge_colors) in Graph.plot() accept any partition of the vertices ( resp. edges ), and let it deal with rainbow to pick the colors. Obviously, it does not mean Graph.plot() should not also be able to support the current dictionary of (color, list)

comment:3 in reply to: ↑ 2 Changed 9 years ago by ncohen

  • Summary changed from Small bug in Graph.plot() to [with patch, needs review] Small bug in Graph.plot()

All the vertices are colored even if vertex_colors did not contain colors for all of them. The first unused color in ranbow() is taken.

There was a small mistake in rgbcolor() where the hexcadecimal values were divided by 256 instead of 255 which lead to "red"!=(1,0,0).

All the colors were wrong and nobody noticed !! :-)

comment:4 Changed 9 years ago by ncohen

  • Milestone set to sage-4.1.2

comment:5 Changed 9 years ago by ncohen

  • Graphfunctions-1 has no reason for being here, but I can not delete it
  • patchplot has been updated, I had forgotten to commit the change from 256 to 255 in rgbcolor()

comment:6 Changed 9 years ago by jason

  • Summary changed from [with patch, needs review] Small bug in Graph.plot() to [with patch, needs work] Small bug in Graph.plot()

The edge color plot in the description works great.

The vertex color plot doesn't. The specified vertex is red; the others disappeared!

Also, it would be great to include those two examples in the docs.

comment:7 Changed 9 years ago by ncohen

Hello Jason !! I sent you an email about this patch some time ago, as I did not understand where this patch failed... Did you get it ? :-)

comment:8 Changed 9 years ago by rlm

  • Authors set to Nathann Cohen
  • Report Upstream set to N/A
  • Reviewers set to Robert Miller
  • Status changed from needs_work to needs_review
  • Summary changed from [with patch, needs work] Small bug in Graph.plot() to Small bug in Graph.plot()

Patch works fine for me.

comment:9 Changed 9 years ago by rlm

  • Status changed from needs_review to positive_review

comment:10 Changed 9 years ago by mhansen

  • Merged in set to sage-4.3.rc1
  • Status changed from positive_review to needs_work

There are test failures in sage/plot/colors.py

Changed 9 years ago by rlm

depends: sage-4.3.1.alpha1 + #7634

comment:11 Changed 9 years ago by rlm

  • Status changed from needs_work to needs_review

comment:12 Changed 9 years ago by rlm

  • Status changed from needs_review to positive_review

comment:13 Changed 9 years ago by rlm

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