# Plotting

Once the graph has been built, 2D plot visualizations are provided by RoMEPlotting.jl and KernelDensityEstimatePlotting.jl. These visualizations tools are readily modifiable to highlight various aspects of mobile platform navigation.

Note

Plotting packages can be installed separately.

## Quick Start

The major 2D plotting functions between RoMEPlotting.jl and KernelDensityEstimatePlotting.jl:

• plotSLAM2D,
• plotPoses,
• plotLandms,
• plotSubmaps,
• plotKDE / plot.

A simple usage example:

using RoMEPlotting

plotPoses(fg)
# If you have landmarks, you can instead call
# plotSLAM2D(fg)

# Draw the KDE for x0
plotKDE(fg, :x0)
# Draw the KDE's for x0 and x1
plotKDE(fg, [:x0, :x1])

## Hexagonal 2D SLAM example visualization

This simplest example for visualizing a 2D robot trajectory–-such as first running the Hexagonal 2D SLAM example–-

# Assuming some fg<:AbstractDFG has been loaded/constructed
# ...

using RoMEPlotting

pl = plotSLAM2D(fg)

# For scripting use-cases you can export the image
Gadfly.draw(PDF("/tmp/test.pdf", 20cm, 10cm),pl)  # or PNG(...) ## Density Contour Map

KernelDensityEstimatePlotting (as used in RoMEPlotting) provides an interface to visualize belief densities as counter plots. The following basic example shows some of features of the API, where plotKDE(..., dims=[1;2]) implies the marginal over variables (x,y):

using RoME, Distributions
using RoMEPlotting

fg = initfg()

ensureAllInitialized!(fg)

# plot one contour density
plX0 = plotKDE(fg, :x0, dims=[1;2])
# using Gadfly; Gadfly.draw(PNG("/tmp/testX0.png",20cm,10cm),plX0) The contour density relates to the distribution of marginal samples as seen with this Gadfly.jl package histogram comparison.

pl1 = drawPoses(fg, to=0);
X0 = getBelief(fg, :x0) |> getPoints;
plH = hstack(pl1, pl2)

# convert to file
# p1H |> PNG("/tmp/testH.png") Note

Red and Green lines represent Port and Starboard direction of Pose2, respectively.

Multiple beliefs can be plotted at the same time, while setting levels=4 rather than the default value:

plX1 = plotKDE(fg, [:x0; :x1], dims=[1;2], levels=4)

# plX1 |> PNG("/tmp/testX1.png") One dimensional (such as Θ) or a stack of all plane projections is also available:

plTh = plotKDE(fg, [:x0; :x1], dims=, levels=4)

# plTh |> PNG("/tmp/testTh.png") plAll = plotKDE(fg, [:x0; :x1], levels=3)
# plAll |> PNG("/tmp/testX1.png",20cm,15cm) Note

The functions hstack and vstack is provided through the Gadfly package and allows the user to build a near arbitrary composition of plots.

Please see KernelDensityEstimatePlotting package source for more features.