I'd like to label a name $K_4$ in following graph. How to do that?
completegraph4 = ImportString["C~", "Graph6"]
All Graphics
options work in Graph
. You can use PlotLabel
or add a Text
primitive to the Epilog
.
label = Style["\!\(\*SubscriptBox[\(K\), \(4\)]\)", 16]
CompleteGraph[4, PlotLabel -> label]
CompleteGraph[4, Epilog -> Text[label, Scaled[{0.8, 0.8}]]]
You could also use Labeled
.
If you want to place the label at the top you can use the option PlotLabel
:
Graph[completegraph4, PlotLabel -> Style["K_4", 16]]
Or wrap the graph object with Labeled
:
Labeled[completegraph4, Style["K_4", 16], Top]
Labeled[completegraph4, Style["K_4", 16], Right]
To get a finer control on label position you can use Legended
+ Placed
:
Legended[completegraph4, Placed[Style["K_4", 16], {.8, .9}]]
You can also use Locator
to place the label interactively:
DynamicModule[{loc = {.8, .8}},
Dynamic @ Show[Graph[completegraph4], Graphics[{Locator[loc, Style["K_4", 16]]}]]]
or
DynamicModule[{loc = {.8, .8}},
Graph[completegraph4, Epilog -> {Dynamic@Locator[loc, Style["K_4", 16]]}]]
Graph[completegraph4, PlotLabel -> Style["K_4", 16]]
? $\endgroup$Labeled[completegraph4, Style["K_4", 16], Top]
? $\endgroup$Graph
which answers all this? $\endgroup$