# Font size for edge label

Simple example:

```
d = DiGraph()
d.add_edge(1, 2, '$a_0$')
d.plot(edge_labels=True)
```

gives me extremely small edge label 'a0', is it possible to increase font size for all edge labels?

Font size for edge label

Simple example:

```
d = DiGraph()
d.add_edge(1, 2, '$a_0$')
d.plot(edge_labels=True)
```

gives me extremely small edge label 'a0', is it possible to increase font size for all edge labels?

add a comment

4

This one took me some time. It can be achieved by opening `YOUR_SAGE_DIR/local/lib/python2.6/site-packages/sage/graphs/graph_plot.py`

and changing the line

```
self._plot_components['edge_labels'].append(text(str(edges_to_draw[(a,b)][0][0]),[(self._pos[a][0]+self._pos[b][0])/2., (self._pos[a][1]+self._pos[b][1])/2.]))
```

to

```
self._plot_components['edge_labels'].append(text(str(edges_to_draw[(a,b)][0][0]),[(self._pos[a][0]+self._pos[b][0])/2., (self._pos[a][1]+self._pos[b][1])/2.],fontsize=20))
```

There is no need to compile anything, just save the file and then run sage.

Remark: in the mentioned file there are 5 lines starting with

```
self._plot_components['edge_labels'].append(text...
```

so to be on the safe side you can change all of them (adding `fontsize=20`

as a last parameter to the `text`

function). I suspect they handle different situations (directed/undirected graphs, etc.). You can put `DEFAULT_FONTSIZE = 20`

at the beginning of the file and then add `fontsize=DEFAULT_FONTSIZE`

to the text functions - this will allow you to change the size easily later.

yep -- the trac server (trac.sagemath.org) lets you select whether the issue you're reporting is a bug or an enhancement.

Asked: **
2011-07-17 02:44:41 -0500
**

Seen: **515 times**

Last updated: **Jul 25 '11**

Can I add mathematical formulas to a plot?

Graph theory: Make vertex labels in plots bigger

How can I display a plot from a script?

TypeError: range() integer end argument expected, got sage.symbolic.expression.Expression.

Overlaying plots in a specific order

Why does graph plotting crop so aggressively, and what is a work-around?

Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.