Tools/Visualization

generated on 2013-11-27 00:42:13.601193 from the wiki page for Tools/Visualization for SUMO 0.19.0

SUMO offers a wide range of outputs, but one may find it hard to parse and visualize them. The suite includes some tools that allow to visualize a simulation run's results so that they can be used in a scientific paper. The tools are implemented in Python and need matplotlib installed.

The tools can be found in <SUMO_HOME>/tools/visualization.

Contents

Current Tools

Below, You will find the descriptions of tools that should work with the current outputs SUMO/SUMO-GUI generate. To run them, you'll need:

  • to install Python
  • to install matplotlib
  • to set <SUMO_HOME>

All scripts are executed from the command line and You have to give the command line options as listed in the descriptions below. Please note that #common options may be applied to all the scripts listed in the following sub-sections.


plot_summary.py

Summary running.png plot_summary.py reads one or multiple summary-files and plots a selected measure (attribute of the read summary-files). The measure is visualised as a time line along the simulation time.

The shown example was generated using the following code:

python plot_summary.py -i mo\summary.xml,dido\summary.xml,fr\summary.xml,sa\summary.xml,so\summary.xml \
 -l Mo,Di-Do,Fr,Sa,So --xlim 0,86400 --ylim 0,10000 -o sumodocs/summary_running.png \
 --yticks 0,10001,2000,14 --xticks 0,86401,14400,14 --xtime1 --ygrid \
 --ylabel "running vehicles [#]" --xlabel "time" --title "running vehicles over time" --adjust .14,.1 

The example shows the numbers of vehicles running in a large-scale scenario of the city of Brunswick over the day for the standard week day classes.

The options of plot_summary.py are shown in the following table:

Option Description
-i <FILE>[,<FILE>]*
--summary-inputs <FILE>[,<FILE>]*
Defines the summary-file(s) to read
-m <STRING>
--measure <STRING>
Defines the measure to read from the summary file; default: running
-v
--verbose
If set, the progress is printed on the screen

plot_tripinfo_distributions.py

Tripinfo distribution duration.png plot_tripinfo_distributions.py reads one or multiple tripinfo-files and plots a selected measure (attribute of the read tripinfo-files). The measure is visualised as vertical bars that represent the numbers of occurences of the measure (vehicles) that fall into a bin.

The shown example was generated using the following code:

python plot_tripinfo_distributions.py \
 -i mo\tripinfo.xml,dido\tripinfo.xml,fr\tripinfo.xml,sa\tripinfo.xml,so\tripinfo.xml \
 -o tripinfo_distribution_duration.png -v -m duration --minV 0 --maxV 3600 --bins 10 \
 --xticks 0,3601,360,14 --xlabel "duration [s]" --ylabel "number [#]" --title "duration distribution" \
 --yticks 14 --xlabelsize 14 --ylabelsize 14 --titlesize 16 -l mon,tue-thu,fri,sat,sun \
 --adjust .14,.1 --xlim 0,3600

The example shows the travel time distribution for the vehicles of different week day classes (Braunschweig scenario).

The options of plot_summary.py are shown in the following table:

Option Description
-i <FILE>[,<FILE>]*
--tripinfos-inputs <FILE>[,<FILE>]*
Defines the summary-file(s) to read
-m <STRING>
--measure <STRING>
Defines the measure to read from the summary file
-v
--verbose
If set, the progress is printed on the screen
--bins <INT> The number of bins to devide the values into
--minV <FLOAT> The minimum value; if set, read values that are lower than this value are set to this value
--maxV <FLOAT> The maximum value; if set, read values that are higher than this value are set to this value

common options

The following options are common to all previously listed tools. They can be divided into two groups:

  • options for formatting the figure (including adding captions etc.)
  • options for determining what to do with the generated figure

The options are listed and discussed in the following sub-sections, respectively.

Formatting Options

Option Description
--colors <COLORS> Uses the given colors; the number of given colors must be the same as the number of measures to plot
--labels <LABELS> Uses the given labels; the number of given labels must be the same as the number of measures to plot
--xlim <XMIN>,<XMAX> Describes the limits of the figure along the x-axis
--xlim <YMIN>,<YMAX> Describes the limits of the figure along the y-axis
--xticks <XMIN>,<XMAX>,<XSTEP>,<XSIZE>
--yticks <XSIZE>
If only one number is given, it is interpreted as the size of the tick labels on the x-axis; if four numbers are given, they are interpreted as the lowest ticks position, the highest ticks position, the step between ticks, and the tick's size, respectively, all along the x-axis
--yticks <XMIN>,<XMAX>,<XSTEP>,<XSIZE>
--yticks <XSIZE>
If only one number is given, it is interpreted as the size of the tick labels on the y-axis; if four numbers are given, they are interpreted as the lowest ticks position, the highest ticks position, the step between ticks, and the tick's size, respectively, all along the y-axis
--xtime1 If set, the tick labels along the x-axis are formatted as time entries (hh:mm)
--ytime1 If set, the tick labels along the y-axis are formatted as time entries (hh:mm)
--xtime2 If set, the tick labels along the x-axis are formatted as time entries (hh:mm:ss)
--ytime2 If set, the tick labels along the y-axis are formatted as time entries (hh:mm:ss)
--xgrid If set, a grid along the ticks on the x-axis is drawn
--ygrid If set, a grid along the ticks on the y-axis is drawn
--xlabel <STRING> Defines the label to set for the x-axis
--ylabel <STRING> Defines the label to set for the y-axis
--xlabelsize <FLOAT> Defines the size of the label of the x-axis
--ylabelsize <FLOAT> Defines the size of the label of the y-axis
--title <STRING> Defines the title of the figure
--titlesize <FLOAT> Defines the size of the title
--adjust <FLOAT>,<FLOAT>
--adjust <FLOAT>,<FLOAT>,<FLOAT>,<FLOAT>
Adjust the plot; If two floats are given, they are interpreted as left and bottom values, if four numbers are given, they are interpreted as left, bottom, right, top
--size <FLOAT>,<FLOAT> Defines the size of figure

Interaction Options

If one of the scripts is simply started with no options that are listed below, the figure will be shown. To write the figure additionally into a file, the filename to generate must be given using the --output <FILE> (or -o <FILE> for short).

If the script is run in a batch file, it is often not convenient to show the figure (once known it is as it should be). In such cases, the option --blind (-b) can be used that suppresses showing the figure.

Option Description
-o <FILE>
--output <FILE>
Defines the name under which the figure shall be saved
-b
--blind
If set, the figure will not be shown

Outdated

The tools are meant to be named as following: <API>__<DESCRIPTION>.py, where:

  • <API>: mpl for matplotlib
  • <DATA>: the SUMO-output that is processed (mainly)
  • <DESCRIPTION>: what the tool does

mpl_dump_twoAgainst.py

Reads two dump files (mandatory options --dump1 <FILE> and --dump2 <FILE>, or, for short -1 <FILE> and -2 <FILE>). Extracts the value described by --value (default: speed). Plots the values of dump2 over the according (same interval time and edge) values from dump1.

Either shows the plot (when --show is set) or saves it into a file (when --output <FILE> is set).

You can additionally plot the normed sums of the value using (--join). In the other case, you can try to use --time-coloring to assign different colors to the read intervals.

You can format the axes by using --xticks <XMIN,XMAX,XSTEP,FONTSIZE> and --yticks <YMIN,YMAX,YSTEP,FONTSIZE> and set theit limits using --xlim <XMIN,XMAX> and --ylim <YMIN,YMAX>. The output size of the image may be set using --size <WIDTH,HEIGHT>.

mpl_tripinfos_twoAgainst.py

Reads two tripinfos files (mandatory options --tripinfos1 <FILE> and --tripinfos2 <FILE>, or, for short -1 <FILE> and -2 <FILE>). Extracts the value described by --value (default: duration). Plots the values of tripinfos2 over the according (same vehicle) values from tripinfos1.

Either shows the plot (when --show is set) or saves it into a file (when --output <FILE> is set).

You can format the axes by using --xticks <XMIN,XMAX,XSTEP,FONTSIZE> and --yticks <YMIN,YMAX,YSTEP,FONTSIZE> and set theit limits using --xlim <XMIN,XMAX> and --ylim <YMIN,YMAX>. The output size of the image may be set using --size <WIDTH,HEIGHT>.

mpl_dump_timeline.py

Reads a value (given as --value <VALUE>, default speed) for edges defined via --edges <EDGEID>[,<EDGEID>]* from the dumps defined via --dumps <DUMP>[,<DUMP>]*. Plots them as time lines, using the colors defined via --colors <MPL_COLOR>[,<MPLCOLOR>]*. Please note that the number of colors must be equal to number of edges * number of dumps.

Either shows the plot (when --show is set) or saves it into a file (when --output <FILENAME> is set).

You can format the axes by using --xticks <XMIN,XMAX,XSTEP,FONTSIZE> and --yticks <YMIN,YMAX,YSTEP,FONTSIZE> and set theit limits using --xlim <XMIN,XMAX> and --ylim <YMIN,YMAX>. The output size of the image may be set using --size <WIDTH,HEIGHT>.

mpl_dump_onNet.py

Reads a network (defined using --net-file <NET> or -n <NET>) and an edge-dump file (--dump <DUMPFILE> or -d <DUMP_FILE>}}). Plots the network using the geometries read from <NET>. Both the width and the colors used for each edge are determined using --value <WIDTHVALUE>,<COLORVALUE> where both <WIDTHVALUE> and <COLORVALUE> are attributes within the dump-file that exist for each edge.

You can change the used color map by setting --color-map <DEFINITION>. <DEFINITION> is made of a sorted list of values (between 0 and 1) and assigned colors. This means that the default 0:#ff0000,.5:#ffff00,1:#00ff00 let streets with low value for <COLORVALUE> appear red, for those in the middle yellow and for those with a high value green. For values between the given values, the color is determined using linear interpolation. Please note that only lowercase hexadecimal characters may be used.

Either shows the plot (when --show is set) or saves it into a file (when --output <FILENAME> is set).

--join sums up the values found for each edge and divides the result by the number of these values. If join is not set and --output is given, one should choose an output name which looks as following: <NAME>'%05d.png. The %05d will be replaced by the current time step written.

If you have generated a set of images by not "joining" (aggregating) the data, you can convert the obtained pictures into an animated gif using ImageMagick and the following command:

convert -delay 20 *.png -loop 0 animation.gif

(loop 0 means that the animation repeats from begin after the end)

You can format the axes by using --xticks <XMIN,XMAX,XSTEP,FONTSIZE> and --yticks <YMIN,YMAX,YSTEP,FONTSIZE> and set theit limits using --xlim <XMIN,XMAX> and --ylim <YMIN,YMAX>. The output size of the image may be set using --size <WIDTH,HEIGHT>.


This page was last modified on 11 November 2013, at 14:12.