I have created a labeled digraph and a legend using SwatchLegend.
transitiontransversion = Labeled[Graph[{
T \[DirectedEdge] T, T \[DirectedEdge] C, T \[DirectedEdge] G,
T \[DirectedEdge] A,
C \[DirectedEdge] C, C \[DirectedEdge] A, C \[DirectedEdge] T,
C \[DirectedEdge] G,
G \[DirectedEdge] G, G \[DirectedEdge] A, G \[DirectedEdge] C,
G \[DirectedEdge] T,
A \[DirectedEdge] A, A \[DirectedEdge] C, A \[DirectedEdge] T,
A \[DirectedEdge] G
}, EdgeStyle -> {A \[DirectedEdge] A -> {Green,
AbsoluteThickness[6], Arrowheads[.05]},
C \[DirectedEdge] C -> {Green, AbsoluteThickness[6],
Arrowheads[.05]},
G \[DirectedEdge] G -> {Green, AbsoluteThickness[6],
Arrowheads[.05]},
T \[DirectedEdge] T -> {Green, AbsoluteThickness[6],
Arrowheads[.05]},
T \[DirectedEdge] C -> {Blue, AbsoluteThickness[6],
Arrowheads[.05]},
C \[DirectedEdge] T -> {Blue, AbsoluteThickness[6],
Arrowheads[.05]},
T \[DirectedEdge] G -> {Red, AbsoluteThickness[6],
Arrowheads[.05]},
T \[DirectedEdge] A -> {Red, AbsoluteThickness[6],
Arrowheads[.05]},
A \[DirectedEdge] G -> {Blue, AbsoluteThickness[6],
Arrowheads[.05]},
G \[DirectedEdge] A -> {Blue, AbsoluteThickness[6],
Arrowheads[.05]},
A \[DirectedEdge] T -> {Red , AbsoluteThickness[6],
Arrowheads[.05]},
A \[DirectedEdge] C -> {Red, AbsoluteThickness[6],
Arrowheads[.05]},
C \[DirectedEdge] A -> {Red, AbsoluteThickness[6],
Arrowheads[.05]},
C \[DirectedEdge] G -> {Red, AbsoluteThickness[6],
Arrowheads[.05]},
G \[DirectedEdge] C -> {Red, AbsoluteThickness[6],
Arrowheads[.05]},
G \[DirectedEdge] T -> {Red, AbsoluteThickness[6],
Arrowheads[.05]}}, VertexSize -> { Large},
VertexStyle -> {A -> Yellow, G -> Yellow, C -> Orange,
T -> Orange}, VertexLabels -> {
A ->
Placed[{Text[Style["Adenine", Bold, 20]],
adenine}, {Center, {-1, 2}}],
C ->
Placed[{Text[Style["Cytosine", Bold, 20]],
cytosine}, {Center, {-1, -1.5}}],
G ->
Placed[{Text[Style["Guanine", Bold, 20]],
guanine}, {Center, {2, 2}}],
T ->
Placed[{Text[Style["Thymine", Bold, 20]],
thymine}, {Center, {2, -1.5}}]
}, ImageSize -> 800,
PlotLabel ->
Text[Style["Molecular Character State Changes", Bold, 30]]],
SwatchLegend[{Green, Blue, Red, Yellow,
Orange}, {Text[Style["Identity Transformations", Bold, 15]],
Text[Style["Transitions", Bold, 15]],
Text[Style["Transversions", Bold, 15]],
Text[Style["Purine", Bold, 15]],
Text[Style["Pyrimidine", Bold, 15]]}, LegendLayout -> "Row"]]
All works as expected. However, when I select the graph object using a mouse right click to save it as a *.png fie, the legend is not included, although the graph itself is nicely rendered as a *.png file.
How does one structure the graph output so that the SwatchLegend also appears in the final saved graphic?
Right-clicking on the Legend, which appears in this case below the bounding box of the graph does not provide the option to save the legend as a graphic.
If an answer to this is present in the documentation, it is well hidden.
Export. – Szabolcs Nov 06 '17 at 15:34BelowwithLegendedis outside. I just noticed that you usedLabeled, which is always outside. When the legend is inside, it counts as a single graphics ... – Szabolcs Nov 06 '17 at 16:38Exportit exports at 80% size. You can use this hack to make them export at 100%. Why does this have to be so complicated? I don't know. The 80%/100% thing doesn't matter to most people, but personally I prepare figures to an exact size in centimetres and export to PDF. I hit this annoying problem regularly. – Szabolcs Nov 06 '17 at 16:40Export, I have gotten used to always usingExportdue to this annoying bug. – Szabolcs Nov 06 '17 at 16:42