@@ -13,18 +13,19 @@ Pkg.add("GraphPlot")
13
13
14
14
Then bring ` GraphPlot ` in before DFG:
15
15
16
- ``` julia
16
+ ``` @example plots; continued = true
17
17
using GraphPlot
18
18
using DistributedFactorGraphs
19
19
```
20
20
21
- Any factor graph can then be drawn by calling ` dfgplot ` :
21
+ Any factor graph can then be drawn by calling [ ` dfgplot ` ] ( @ref ) :
22
22
23
- ``` julia
23
+ ``` @example plots
24
+ using Cairo # hide
24
25
# Construct graph using IIF
25
26
using IncrementalInference
26
27
# Create graph
27
- dfg = LightDFG {SolverParams} (params = SolverParams ())
28
+ dfg = LightDFG{SolverParams}(solverParams =SolverParams())
28
29
v1 = addVariable!(dfg, :x0, ContinuousScalar, labels = [:POSE], solvable=1)
29
30
v2 = addVariable!(dfg, :x1, ContinuousScalar, labels = [:POSE], solvable=1)
30
31
v3 = addVariable!(dfg, :l0, ContinuousScalar, labels = [:LANDMARK], solvable=1)
@@ -37,19 +38,22 @@ f1 = addFactor!(dfg, [:l0; :x1], LinearConditional(Normal(-10.0,5.0)), solvable=
37
38
dfgplot(dfg)
38
39
```
39
40
40
- ![ imgs/initialgraph.jpg] ( imgs/initialgraph.jpg )
41
-
42
- - [ ` dfgplot ` ] ( @ref )
43
-
44
41
### Rendering GraphPlot to PDF
45
42
46
- The graph can be rendered to PDF or JPG in the following way:
43
+ The graph can be rendered to PDF, SVG or JPG in the following way by including compose :
47
44
48
- ``` julia
49
- # Save to PDF
45
+ ``` @example plots
50
46
using Compose
51
- draw (PDF (" /tmp/graph.pdf" , 16 cm, 16 cm), dfgplot (dfg))
47
+ # lets add another variable and factor and plot it
48
+ dfg.solverParams.graphinit = false # hide
49
+ addVariable!(dfg, :x2, ContinuousScalar);
50
+ addFactor!(dfg, [:x1; :x2], LinearConditional(Normal(50.0,2.0)));
51
+ # Save to SVG
52
+ draw(SVG("graph.svg", 10cm, 10cm), dfgplot(dfg));
53
+ nothing # hide
52
54
```
55
+ ![ ] ( graph.svg )
56
+
53
57
54
58
### More Information
55
59
@@ -63,12 +67,12 @@ and can be drawn by either:
63
67
- Calling [ ` toDot ` ] ( @ref ) on any graph to produce a string of the graph
64
68
- Calling [ ` toDotFile ` ] ( @ref ) on any graph to save it directly to a dotfile
65
69
66
- ``` julia
70
+ ``` @example
67
71
using DistributedFactorGraphs
68
72
# Construct graph using IIF
69
73
using IncrementalInference
70
74
# Create graph
71
- dfg = GraphsDFG {SolverParams} (params = SolverParams ())
75
+ dfg = LightDFG {SolverParams}(solverParams =SolverParams())
72
76
v1 = addVariable!(dfg, :x0, ContinuousScalar, labels = [:POSE], solvable=1)
73
77
v2 = addVariable!(dfg, :x1, ContinuousScalar, labels = [:POSE], solvable=1)
74
78
v3 = addVariable!(dfg, :l0, ContinuousScalar, labels = [:LANDMARK], solvable=1)
@@ -79,5 +83,6 @@ f1 = addFactor!(dfg, [:l0; :x1], LinearConditional(Normal(-10.0,5.0)), solvable=
79
83
# Save to dot file
80
84
toDotFile(dfg, "/tmp/test.dot")
81
85
# Open with xdot
82
- run (` xdot /tmp/test.dot` )
86
+ # run(`xdot /tmp/test.dot`)
87
+ # nothing # hide
83
88
```
0 commit comments