1
$\begingroup$

I worked out how (one way...) to import a .dot graph format file into Mathematica using

Import["/home/username/Desktop/mygraph.dot"]

which works a treat, drawing a nice graph with vertices and edges all joined up.

But can anyone please explain how I can make the vertex labels either bigger, or add a coloured background to the label text?

I have many edges between vertices and as it is the thin black small text is difficult to read.

Thanks

$\endgroup$
2
$\begingroup$

You can add Graphoptions during Importing. That is, if example.dot is the file to be imported

Export["example.dot", Import["ExampleData/sample.gv"], "DOT"]

"example.dot"

you can import it as follows

Import["example.dot", ImagePadding -> 20, ImageSize -> 400, 
  VertexLabelStyle -> 16, EdgeStyle -> Directive[Red, Thick]] 

to get

enter image description here

This feature is documented in DOT >> Options:

enter image description here

Alternatively, if you already imported the graph, you can use SetProperty to make changes in any of the Graph options:

g2 = Import["example.dot"]

enter image description here

SetProperty[g2, {VertexLabelStyle -> 16, EdgeStyle -> Directive[Red, Thick], 
  ImageSize -> 400, ImagePadding -> 30}]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.