Skip to main content

A python library to render Sumo network files and trajectories with matplotlib.

Project description


A Python library for visualizing a Sumo network and trajectories with matplotlib.

Example plot of an intersection with trajectory colored by speed Example plot of an curving road with bike lanes Example animation

Basic trajectory plotting from FCD outputs is built in, but it is also possible to plot custom data and graphics on top of the network with the full flexibility and power of matplotlib and other compatible libraries, such as seaborn.


This package can be installed via pip with the command pip install SumoNetVis. You can then import the library with:

import SumoNetVis


  • shapely
  • matplotlib
  • numpy


To plot a Sumo net file and trajectories, you can use the following code:

import SumoNetVis
import matplotlib.pyplot as plt
# Plot Sumo Network
net = SumoNetVis.Net("path/to/")
# Plot trajectories
trajectories = SumoNetVis.Trajectories("path/to/fcd-output.xml")
# Show figure

You also have the option of passing a matplotlib Axes object to the plot methods.


Instead of visualizing Trajectories as lines, an animation can be generated using the matplotlib.animation module.

import matplotlib.animation as animation
trajectories = SumoNetVis.Trajectories("path/to/fcd-output.xml")
fig, ax = plt.subplots()
a = animation.FuncAnimation(fig, trajectories.plot_points, frames=trajectories.timestep_range(), repeat=False,
                            interval=1000*trajectories.timestep, fargs=(ax,), blit=True)

The plot settings for each vehicle can be customized and the color of each point can be animated, as shown in the following example.

for trajectory in trajectories:
        trajectory.point_plot_kwargs["ms"] = 8  # set marker size. Can set any kwargs taken by matplotlib.pyplot.plot().

In order to animate the color of the points based on the assigned color scheme, an additional farg must be passed when creating the animation.

a = animation.FuncAnimation(fig, trajectories.plot_points, frames=trajectories.timestep_range(), repeat=False,
                            interval=1000*trajectories.timestep, fargs=(ax, True), blit=True)


Issues and pull requests are welcome.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for SumoNetVis, version 1.1.0
Filename, size File type Python version Upload date Hashes
Filename, size SumoNetVis-1.1.0.tar.gz (8.5 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page