Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How change font size of Graph vertex labels?

411 views
Skip to first unread message

Murray Eisenberg

unread,
Mar 11, 2011, 4:36:16 AM3/11/11
to
I want to make the "Names" labels of vertices in a Graph larger. The
"obvious" way...

Graph[{1, 2, 3},
{DirectedEdge[1, 2], DirectedEdge[2, 3], DirectedEdge[3, 1]},
{VertexLabels -> {Placed["Name", Center]}, VertexSize -> {Medium},
VertexStyle -> {24}}]

...seems to do nothing. And replacing the option VertexStyle -> {24}
with the wordier VertexStyle -> {FontSize->24} prevents Mathematica from
evaluating the Graph expression at all.

(Mathematica 8.0.1)
--
Murray Eisenberg mur...@math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower phone 413 549-1020 (H)
University of Massachusetts 413 545-2859 (W)
710 North Pleasant Street fax 413 545-1801
Amherst, MA 01003-9305

Armand Tamzarian

unread,
Mar 12, 2011, 5:10:37 AM3/12/11
to
On Mar 11, 8:36 pm, Murray Eisenberg <murrayeisenb...@gmail.com>
wrote:

This works but may not be the most efficient way of doing it:

VertexRenderingFunction -> (Text[Framed[Style[#2, 24, Bold, Blue],
frame options, rounding radius etc.], #1] &)

Mike

Armand Tamzarian

unread,
Mar 12, 2011, 5:11:39 AM3/12/11
to
On Mar 11, 8:36 pm, Murray Eisenberg <murrayeisenb...@gmail.com>
wrote:
> I want to make the "Names" labels of vertices in a Graph larger. The
> "obvious" way...
>
> Graph[{1, 2, 3},
> {DirectedEdge[1, 2], DirectedEdge[2, 3], DirectedEdge[3, 1]},
> {VertexLabels -> {Placed["Name", Center]}, VertexSize -> {Med=

ium},
> VertexStyle -> {24}}]
>
> ...seems to do nothing. And replacing the option VertexStyle -> {24}
> with the wordier VertexStyle -> {FontSize->24} prevents Mathematica from
> evaluating the Graph expression at all.
>
> (Mathematica 8.0.1)
> --
> Murray Eisenberg mur...@math.umas=

s.edu
> Mathematics & Statistics Dept.
> Lederle Graduate Research Tower phone 413 549-1020 (H)
> University of Massachusetts 413 545-2859 (=

W)
> 710 North Pleasant Street fax 413 545-1801
> Amherst, MA 01003-9305


My previous answer was based on my last usage of graphs which was over
18 months ago with version 7 and it turns out that
VertexRenderingFunction is for GraphPlot not Graph. Not immediately
clear why two separate functions,GraphPlot and Graph, are needed and
when you use one or the other, but I don't use graphs so haven't read
up on it.

Looks like some nice new features in 8. Right click on a graph to make
many changes. Shame we do not have this sort of contextual menu driven
editing of plots because I venture to say that the usage of basic
plots (Plot, ListLinePlot ...) would be orders of magnitude greater
than the usage of graphs. But it looks like a step in the right
direction.

For Graph, More Information list VertexLabelStyle, which is what you
need. This is another option without a usage example -- something that
seems to be creeping into Mathematica releases these days.

Graph[{1, 2, 3}, {DirectedEdge[1, 2], DirectedEdge[2, 3],
DirectedEdge[3, 1]}, {VertexLabels -> {Placed["Name", Center]},

VertexSize -> {Medium}, VertexLabelStyle -> {24}}]

Graph[{1, 2, 3}, {DirectedEdge[1, 2], DirectedEdge[2, 3],
DirectedEdge[3, 1]}, {VertexLabels -> {Placed["Name", Center]},
VertexSize -> {Medium},

VertexLabelStyle -> Directive[FontFamily -> "Helvetica", 24, Blue]}]


Mike

Lou

unread,
Mar 12, 2011, 5:12:12 AM3/12/11
to
On 11 mrt, 10:36, Murray Eisenberg <murrayeisenb...@gmail.com> wrote:
> I want to make the "Names" labels of vertices in a Graph larger. The
> "obvious" way...
>
> Graph[{1, 2, 3},
> {DirectedEdge[1, 2], DirectedEdge[2, 3], DirectedEdge[3, 1]},
> {VertexLabels -> {Placed["Name", Center]}, VertexSize -> {Med=

ium},
> VertexStyle -> {24}}]
>
> ...seems to do nothing. And replacing the option VertexStyle -> {24}
> with the wordier VertexStyle -> {FontSize->24} prevents Mathematica from
> evaluating the Graph expression at all.
>
> (Mathematica 8.0.1)
> --
> Murray Eisenberg mur...@math.umas=

s.edu
> Mathematics & Statistics Dept.
> Lederle Graduate Research Tower phone 413 549-1020 (H)
> University of Massachusetts 413 545-2859 (=

W)
> 710 North Pleasant Street fax 413 545-1801
> Amherst, MA 01003-9305

Hi Marray,
This worked for me mm8.01


Graph[{1, 2, 3}, {DirectedEdge[1, 2], DirectedEdge[2, 3],
DirectedEdge[3, 1]}, {VertexLabels -> {Placed["Name", Center]},
VertexSize -> {Medium},

VertexLabelStyle -> Directive[Black, Italic, Underlined, 45]}]

Kind regards,
Lou

Bob Hanlon

unread,
Mar 12, 2011, 5:13:11 AM3/12/11
to

Use VertexLabelStyle

Graph[{1, 2, 3}, {DirectedEdge[1, 2], DirectedEdge[2, 3],
DirectedEdge[3, 1]}, {VertexLabels -> {Placed["Name", Center]},

VertexSize -> {Medium}, VertexLabelStyle -> {24}}]


Bob Hanlon

---- Murray Eisenberg <murraye...@gmail.com> wrote:

=============


I want to make the "Names" labels of vertices in a Graph larger. The
"obvious" way...

Graph[{1, 2, 3},
{DirectedEdge[1, 2], DirectedEdge[2, 3], DirectedEdge[3, 1]},

{VertexLabels -> {Placed["Name", Center]}, VertexSize -> {Medium},
VertexStyle -> {24}}]

...seems to do nothing. And replacing the option VertexStyle -> {24}
with the wordier VertexStyle -> {FontSize->24} prevents Mathematica from
evaluating the Graph expression at all.

(Mathematica 8.0.1)
--
Murray Eisenberg mur...@math.umass.edu


Mathematics & Statistics Dept.
Lederle Graduate Research Tower phone 413 549-1020 (H)

University of Massachusetts 413 545-2859 (W)

Helen Read

unread,
Mar 12, 2011, 5:20:29 AM3/12/11
to
On 3/11/2011 4:36 AM, Murray Eisenberg wrote:
> I want to make the "Names" labels of vertices in a Graph larger. The
> "obvious" way...
>
> Graph[{1, 2, 3},
> {DirectedEdge[1, 2], DirectedEdge[2, 3], DirectedEdge[3, 1]},
> {VertexLabels -> {Placed["Name", Center]}, VertexSize -> {Medium},
> VertexStyle -> {24}}]
>
> ...seems to do nothing. And replacing the option VertexStyle -> {24}
> with the wordier VertexStyle -> {FontSize->24} prevents Mathematica from
> evaluating the Graph expression at all.
>
> (Mathematica 8.0.1)


VertexStyle is for the vertices themselves. Use VertexLabelStyle to
style the VertexLabels.

Graph[{1, 2, 3}, {DirectedEdge[1, 2], DirectedEdge[2, 3],
DirectedEdge[3, 1]}, {VertexLabels -> {Placed["Name", Center]},

VertexSize -> {Medium}, VertexStyle -> Red, VertexLabelStyle -> 24}]

--
Helen Read
University of Vermont

Murray Eisenberg

unread,
Mar 13, 2011, 6:29:26 AM3/13/11
to
Yes, VertexLabelStyle is the Graph option to use to change the size,
etc., of vertex labels.

Although VertexLabelStyle is listed among the huge list within the More
Information section of the Graph page, and although the item in that
list does have a link to a separate doc page for VertexLabelStyle, oddly
the option is NOT listed in the Options section of the Graph page.
Clearly an omission.

On 3/12/2011 5:11 AM, Bob Hanlon wrote:
> Use VertexLabelStyle


>
> Graph[{1, 2, 3}, {DirectedEdge[1, 2], DirectedEdge[2, 3],
> DirectedEdge[3, 1]}, {VertexLabels -> {Placed["Name", Center]},

> VertexSize -> {Medium}, VertexLabelStyle -> {24}}]
>
>
> Bob Hanlon
>
> ---- Murray Eisenberg<murraye...@gmail.com> wrote:
>
> =============

> I want to make the "Names" labels of vertices in a Graph larger. The
> "obvious" way...
>
> Graph[{1, 2, 3},
> {DirectedEdge[1, 2], DirectedEdge[2, 3], DirectedEdge[3, 1]},
> {VertexLabels -> {Placed["Name", Center]}, VertexSize -> {Medium},
> VertexStyle -> {24}}]
>
> ...seems to do nothing. And replacing the option VertexStyle -> {24}
> with the wordier VertexStyle -> {FontSize->24} prevents Mathematica from
> evaluating the Graph expression at all.
>
> (Mathematica 8.0.1)

--

Bob Hanlon

unread,
Mar 14, 2011, 7:00:43 AM3/14/11
to

I agree that all of the options should be on the help page; at the same time, the documentation is more than just the help pages. When I have a problem, I also use autocomplete to find information, e.g. type Vertex and then Command+k (Mac). Equivalently, use Names:

Names["Vertex*"] // Column


Bob Hanlon

---- Murray Eisenberg <mur...@math.umass.edu> wrote:

=============


--

Bob Hanlon


0 new messages