Ticket #13891: trac_13891-third_pass.patch
File trac_13891-third_pass.patch, 7.2 KB (added by , 6 years ago) |
---|
-
sage/combinat/posets/posets.py
# HG changeset patch # User Nathann Cohen <nathann.cohen@gmail.com> # Date 1359110977 -3600 # Node ID e3d66ffe7e46871675c18f49f13c4120cc160319 # Parent 18aba22e780a4504c975c79c0b4383cd687e8ac7 Default parameters for Graph.plot() and Graph.show() -- third pass diff --git a/sage/combinat/posets/posets.py b/sage/combinat/posets/posets.py
a b 1399 1399 sage: D.show(element_labels=elm_labs) 1400 1400 """ 1401 1401 self.plot(label_elements=label_elements, element_labels=element_labels, 1402 label_font_size=label_font_size,label_font_color=label_font_color,1403 1402 vertex_size=vertex_size, vertex_colors=vertex_colors, layout=layout).show(**kwds) 1404 1403 1405 1404 def level_sets(self): -
sage/graphs/generic_graph.py
diff --git a/sage/graphs/generic_graph.py b/sage/graphs/generic_graph.py
a b 13800 13800 Here is the list of all the available layout options:: 13801 13801 13802 13802 sage: from sage.graphs.graph_plot import layout_options 13803 sage: list(sorted(layout_options.iteritems())) 13804 [('by_component', 'Whether to do the spring layout by connected component -- a boolean.'), 13805 ('dim', 'The dimension of the layout -- 2 or 3.'), 13806 ('heights', 'A dictionary mapping heights to the list of vertices at this height.'), 13807 ('iterations', 'The number of times to execute the spring layout algorithm.'), 13808 ('layout', 'A layout algorithm -- one of "acyclic", "circular", "ranked", "graphviz", "planar", "spring", or "tree".'), 13809 ('prog', 'Which graphviz layout program to use -- one of "circo", "dot", "fdp", "neato", or "twopi".'), 13810 ('save_pos', 'Whether or not to save the computed position for the graph.'), 13811 ('spring', 'Use spring layout to finalize the current layout.'), 13812 ('tree_orientation', 'The direction of tree branches -- "up" or "down".'), 13813 ('tree_root', 'A vertex designation for drawing trees.')] 13803 sage: for key, value in list(sorted(layout_options.iteritems())): 13804 ... print "option", key, ":", value 13805 option by_component : Whether to do the spring layout by connected component -- a boolean. 13806 option dim : The dimension of the layout -- 2 or 3. 13807 option heights : A dictionary mapping heights to the list of vertices at this height. 13808 option iterations : The number of times to execute the spring layout algorithm. 13809 option layout : A layout algorithm -- one of : "acyclic", "circular" (plots the graph with vertices evenly distributed on a circle), "ranked", "graphviz", "planar", "spring" (traditional spring layout, using the graph's current positions as initial positions), or "tree" (the tree will be plotted in levels, depending on minimum distance for the root). 13810 option prog : Which graphviz layout program to use -- one of "circo", "dot", "fdp", "neato", or "twopi". 13811 option save_pos : Whether or not to save the computed position for the graph. 13812 option spring : Use spring layout to finalize the current layout. 13813 option tree_orientation : The direction of tree branches -- "up" or "down". 13814 option tree_root : A vertex designation for drawing trees. a vertex of the tree to be used as the root for the ``layout="tree"`` option. If no root is specified, then one is chosen at random. Ignored unless ``layout='tree'`` 13814 13815 13815 13816 Some of them only apply to certain layout algorithms. For 13816 13817 details, see :meth:`.layout_acyclic`, :meth:`.layout_planar`, -
sage/graphs/graph_plot.py
diff --git a/sage/graphs/graph_plot.py b/sage/graphs/graph_plot.py
a b 72 72 for key, value in graphplot_options.iteritems(): 73 73 __doc__ += " ``"+str(key)+"`` | "+str(value)+"\n" 74 74 75 75 76 __doc__ += """ 76 77 77 **Default options** 78 78 79 79 This module defines two dictionaries containing default options for the … … 212 212 Wrong input:: 213 213 214 214 sage: graphs.PetersenGraph().plot(kujhfuhf="23") 215 doctest:...: DeprecationWarning: kujhfuhf is not a registered argument forGraphPlot ! Please tell us that if it should be by writing to sage-devel ! 215 doctest:...: DeprecationWarning: You provided kujhfuhf as an 216 argument to a function which has always silently ignored its 217 inputs. This method may soon be updated so that the method raises an 218 exception instead of this warning, which will break your code : to 219 be on the safe side, update it ! 216 220 ... 217 221 """ 218 222 # Setting the default values if needed … … 223 227 for opt in options: 224 228 if not opt in graphplot_options: 225 229 from sage.misc.superseded import deprecation 226 deprecation(13891, (str(opt)+" is not a registered argument for"+ 227 "GraphPlot ! Please tell us that if it "+ 228 "should be by writing to sage-devel !")) 230 deprecation(13891, ("You provided "+str(opt)+" as an argument to a " 231 "function which has always silently ignored " 232 "its inputs. This method may soon be updated " 233 "so that the method raises an exception " 234 "instead of this warning, which will break " 235 "your code : to be on the safe side, update it !")) 229 236 230 237 self._plot_components = {} 231 238 self._nodelist = graph.vertices() … … 701 708 702 709 self.plot().show(**kwds) 703 710 704 def plot(self ):711 def plot(self, **kwds): 705 712 """ 706 713 Returns a graphics object representing the (di)graph. 707 714 … … 843 850 sage: g.add_edges([(0,0,'a'),(0,0,'b'),(0,1,'c'),(0,1,'d'), 844 851 ... (0,1,'e'),(0,1,'f'),(0,1,'f'),(2,1,'g'),(2,2,'h')]) 845 852 sage: g.graphplot(edge_labels=True, color_by_label=True, edge_style='dashed').plot() 853 854 Wrong input (any input) :trac:`13891`:: 855 856 sage: graphs.PetersenGraph().graphplot().plot(aertataert=346345345) 857 doctest:...: DeprecationWarning: This method takes no argument ! You may want to give it as an argument to graphplot instead. 858 See http://trac.sagemath.org/13891 for details. 859 <BLANKLINE> 846 860 """ 861 # This method takes NO input 862 # This has been added in early 2013. Remove it before my death, please. 863 if kwds: 864 from sage.misc.superseded import deprecation 865 deprecation(13891, "This method takes no argument ! You may want " 866 "to give it as an argument to graphplot instead.") 867 847 868 G = Graphics() 848 869 for comp in self._plot_components.values(): 849 870 if not isinstance(comp, list): … … 851 872 else: 852 873 for item in comp: 853 874 G += item 875 854 876 G.set_axes_range(*(self._graph._layout_bounding_box(self._pos))) 855 877 if self._options['graph_border']: 856 878 xmin = G.xmin()