3
$\begingroup$

We construct a graph as the following.

node = {11, 12, 13, 14, 15, 16};
edges = {11 -> 14, 11 -> 16, 12 -> 16, 12 -> 15, 13 -> 15, 13 -> 16, 
         14 -> 16, 14 -> 15, 15 -> 16, 15 -> 13, 16 -> 15, 16 -> 14};
vertexposition = {{6.51493919050084`, 44.04756585632944`}, 
    {75.59445680043342`, 50.47455242214042`}, 
    {87.32825501506514`, 13.395648943951699`}, 
    {28.795707353492418`, 3.420138063734413`}, 
    {60.729164933330765`, 16.915777496473908`}, 
    {51.85158892659126`, 25.803692768150313`}};
Show[
    Graph[node, edges, VertexCoordinates -> vertexposition, 
          VertexSize -> {"Scaled", .02},VertexLabels -> "Name"],
    Frame -> True, FrameTicks -> True, ImageSize -> 600]

enter image description here

  1. Now in the above graph how can I can control the size of the Arrowheads and thickness/color/opacity of the lines?
  2. Is there any options that I can use to make the graph aesthetically more eye catching (sorry for using a qualitative term!)?
  3. Without using Show can I display the frame and the axes values directly in a Graph?
$\endgroup$
  • 3
    $\begingroup$ Have you checked the docs? There are really so many examples there of exactly what you are asking for. Please do try to find the solution before you post such a question, and do describe what you tried so far and why it wasn't good enough. $\endgroup$ – Szabolcs Feb 29 '12 at 13:02
9
$\begingroup$

For the first part of your question you can use a custom function for the EdgeShapeFunction option of Graph:

Let

   edgeshape[e_, ___] := {Arrowheads[Large], Red, Thick, Arrow[e, 0.2]}

and use as

 Show[Graph[node, edges, VertexCoordinates -> vertexposition, 
 VertexSize -> {"Scaled", .02}, VertexLabels -> "Name", 
 EdgeShapeFunction -> edgeshape], Frame -> True, FrameTicks -> True, 
 ImageSize -> 600]

to get

enter image description here

Graph also takes Graphics options, so you can use

 Graph[node, edges, VertexCoordinates -> vertexposition, 
 VertexSize -> {"Scaled", .02}, VertexLabels -> "Name", 
 EdgeShapeFunction -> edgeshape, Axes -> True, Ticks -> Automatic, 
 TicksStyle -> Directive[Orange, 12], PlotRangePadding -> .1, 
  AxesOrigin -> {0, 0}]

to get

enter image description here

Update: Using Szabolcs's revised answer, adding Frame->True, FrameTicks->All to options

 Graph[node, edges, VertexCoordinates -> vertexposition, 
 VertexSize -> {"Scaled", .02}, VertexLabels -> "Name", 
 EdgeShapeFunction -> edgeshape, Frame -> True, Axes -> False, 
 FrameTicks -> All, FrameTicksStyle -> Directive[Orange, 12]]!

enter image description here

You can also define your custom tick function. e.g.

 ticks[min_, max_] := 
 Table[If[EvenQ[i], {i, i, {.01, 0}, Red}, {i, i, {.01, 0},  Blue}], {i, Floor[min],   Floor[max], 10}]

and use it with FrameTicks

 Graph[node, edges, VertexCoordinates -> vertexposition, 
 VertexSize -> {"Scaled", .02}, VertexLabels -> "Name", 
  EdgeShapeFunction -> edgeshape, Frame -> True, Axes -> False, 
 FrameTicks -> ticks, FrameTicksStyle -> Directive[Orange, 12], 
 PlotRangePadding -> 5, ImagePadding -> 30]

to get

enter image description here

From the above answers to your first and third questions, you should be glad that i am not attempting to answer your second question.

$\endgroup$
8
$\begingroup$
  1. Use EdgeStyle with Arrowheads, Thickness, colour specifications, Opacity.

  2. Please see http://reference.wolfram.com/mathematica/guide/GraphStylingAndLabeling.html

  3. Graph will take the same options as Graphics so you can use Frame -> True, FrameTicks -> All

The docs have plenty of examples.

$\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.