ASKSAGE: Sage Q&A Forum - Latest question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 06 Apr 2016 16:30:18 -0500Position of labels in a graphhttps://ask.sagemath.org/question/33025/position-of-labels-in-a-graph/I'm creating a labeled graph, but the position of the labels is making them difficult to read. For example:
D = DiGraph(multiedges=True)
D.add_edge(var('Vert1'),var('Vert2'),str("Edge1"))
D.add_edge(var('Vert2'),var('Vert3'),str("Edge2"))
D.add_edge(var('Vert1'),var('Vert3'),str("Edge3"))
D.graphplot(edge_labels=True,layout='circular').show()
creates a nice looking graph, but especially `Edge1` is difficult to read. Is there a way to move labels away from the edges?
I know there are posts asking similar questions (insufficient karma to post links), though these suggest changing the rule for label location to be something other than the middle of the two points, and I'd rather not have to use the same rule for all labels, as the changes may be different for different vertices.
EDIT: I have a sort-of solution, which is just to add spaces in the label name or line breaks in the label name, which does achieve the goal, but if someone has a better solution, I would be very happy to hear it. E.g.:
D = DiGraph(multiedges=True)
D.add_edge(var('Vert1'),var('Vert2'),str("""Edge1
"""))
D.add_edge(var('Vert2'),var('Vert3'),str(" Edge2"))
D.add_edge(var('Vert1'),var('Vert3'),str(" Edge3"))
D.graphplot(edge_labels=True,layout='circular').show()
mthomasWed, 06 Apr 2016 16:30:18 -0500https://ask.sagemath.org/question/33025/edge labels and vertex size causes problemshttps://ask.sagemath.org/question/10776/edge-labels-and-vertex-size-causes-problems/Hi,
I have several problems creating a graph. I want to misuse the graph tools in sagemath to create a flow diagram, but I encountered two problems:
First, the vertex_size option does not work at all in my code and
second, relating to the question
[here](http://ask.sagemath.org/question/1700/getting-edge-labels-in-a-digraph-to-display), is there now a possibility to shift the edge labels?
I work with sage 5.9 in a virtual box environment
from sage.graphs.graph_plot import GraphPlot
h = DiGraph({0:[1,2], 1:[3], 2:[4]})
for u,v,l in h.edges():
h.set_edge_label(u,v,'(' + str(u) + ',' + str(v) + ')')
h1=h.graphplot(save_pos=True, edge_labels=True, talk=True)
h1.show()
print h.get_pos()
h.set_pos({0:[0,0],1:[1,1],2:[1,-1],3:[2,1],4:[3,-1]})
h1=h.graphplot(save_pos=True, edge_labels=True, talk=True, vertex_size=0)
h1.set_vertices(vertex_shape='s')
h1.show()
Thanks in advance.god.oneMon, 25 Nov 2013 21:33:26 -0600https://ask.sagemath.org/question/10776/