4
$\begingroup$

In an attempt to create a legend for a graph drawing, I find that Labeled only works without the position options (except for Center).

   Graph[Range[2], {
  Labeled[DirectedEdge[1, 2], "BEFORE"]}]

enter image description here

But

Graph[Range[2], {
  Labeled[DirectedEdge[1, 2], "BEFORE", Bottom]}]

enter image description here

Similarly for the other Labeled position options like Top, Left, Right.

Also, adding ImagePadding doens't help. I've tried some - but not all - Labeled's other options:

{Alignment -> {Center, Baseline}, Background -> None, 
 BaselinePosition -> Automatic, BaseStyle -> {}, 
 DefaultBaseStyle -> "Labeled", DefaultLabelStyle -> "LabeledLabel", 
 Editable -> Automatic, Frame -> None, FrameMargins -> 0, 
 FrameStyle -> Automatic, ImageMargins -> 0, ImageSize -> Automatic, 
 LabelStyle -> {}, RotateLabel -> False, RoundingRadius -> 0, 
 Selectable -> Automatic, Spacings -> Automatic, 
 SyntaxForm -> Automatic}

Known issue?

$\endgroup$
  • $\begingroup$ I think that with Bottom the label falls below the plot area and thus does not show... try setting the option PlotRange to show a larger vertical area. $\endgroup$ – becko May 11 '13 at 3:32
5
$\begingroup$

I do not see any advantage of using Labeled vs intended for graphs EdgeLabels. Here is an aap to demonstrate arbitrary label placement:

Manipulate[Graph[{1 \[DirectedEdge] 2}, EdgeLabels -> {1 \[DirectedEdge] 2 -> 
  Placed[Style["OVERLAP", Red, 15], {a, p}]}, 
  PlotRange -> {{-.5, 1.5}, {-.15, .15}}, EdgeShapeFunction -> esf],
  {{esf, "Arrow", "Arrowheads"}, {"Line", "Arrow"}},
  {{p, {.5, .7}, "scaled position\nin the label"}, {-2, 0}, {3, 1.5}}, 
  {{a, .5, "scaled position of\nthe label along edge"}, 0, 1}]

enter image description here

$\endgroup$
  • 2
    $\begingroup$ that's an option but my intention is to build legends for graphs, using Row, Column, Grid. In any case, something is broken in Labeled-Graph interaction. $\endgroup$ – alancalvitti Sep 7 '12 at 20:37
  • $\begingroup$ @alancalvitti Can you show how you intend to use Row, etc. for this? $\endgroup$ – Vitaliy Kaurov Sep 7 '12 at 20:48
  • $\begingroup$ for example: Column[{ Column[{"OVERLAP", Graph[{Style[DirectedEdge[1, 2], Red]}, ImageSize -> 150]}, Center, -0.5], Column[{"BEFORE", Graph[{Style[DirectedEdge[1, 2], Blue]}, ImageSize -> 150]}, Center, -0.5], Column[{"AFTER", Graph[{Style[DirectedEdge[1, 2], Green]}, ImageSize -> 150]}, Center, -0.5] }] $\endgroup$ – alancalvitti Sep 7 '12 at 20:51
  • $\begingroup$ I suppose all this can be done within Graph by specifying vertex positions, but I prefer not specifying all these small details. $\endgroup$ – alancalvitti Sep 7 '12 at 20:52
  • 1
    $\begingroup$ @VitaliyKaurov,+1 but cannot accept. The issue is the orthogonality of the language. Why don't all Labeled options work with Graph? $\endgroup$ – alancalvitti Sep 8 '12 at 18:08

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.