Interactive module

This module provides the necessary functions to start up a local HTTP server and open an interactive d3-visualization of one or several temporal networks.

class tacoma.interactive.StoppableHTTPServer(server_address, handler, subfolder)[source]

Bases: http.server.HTTPServer

Taken from


Download d3.v4.min.js and save it in ~/.tacoma/d3, if the file does not exist yet.

tacoma.interactive.prepare_export_directory(d, subdir)[source]

Move all files from the tacoma/interactive directory to directory d


Move all files from the tacoma/interactive directory to ~/.tacoma/web

tacoma.interactive.visualize(temporal_networks, frame_dt, time_normalization_factor=1, time_unit=None, titles=None, config=None, port=8226, export_path=None)[source]

Visualize a temporal network or a list of temporal networks interactively. This routine starts up an HTTP server, bins the networks according to the time step frame_dt and copies them to ~/.tacoma/web. Subsequently, a the interaction is started in the standard browser.

The visualization is stopped with KeyboardInterrupt. The temporary temporal network files will subsequently be deleted.

  • temporal_networks (an instance of _tacoma.edge_changes, _tacoma.edge_lists, _tacoma.edge_lists_with_histograms, _tacoma.edge_changes_with_histograms or a list containing those.) – The temporal networks to visualize. If a list is provided, all networks need to have the same t0 and tmax.
  • frame_dt (float) –

    The duration of a frame in the visualization.


    This has to be given in the original time units of the temporal network, disregarding any value of time_normalization_factor.

  • time_normalization_factor (float, default : 1.0) – Rescale time with this factor.
  • time_unit (string, default : None,) – Unit of time of the visualization.
  • titles (string or list of strings, default : None) – Titles to put on the figures of the corresponding temporal networks.
  • config (dict or str) – Configuration values for the JavaScript visualization. If this is a string, it can be either hs13, dtu, or ht09 and the appropriate configuration is loaded.
  • port (int, default : 8226) – Port of the started HTTP server.
  • export_path (string, default : None) –

    path to a directory to which the whole visualization is copied. Use os.get_cwd()+'/export_dir/' for the current working directory (after import os).


    No subdirectory will be made for the export. All visualization files will be exported to export_path directly.


The configuration dictionary is filled with values to control the appearance of the visualizations. The standard configuration is

config = {
    "plot_width" : 320 ,
    "network_plot_height" : 250,
    "edges_plot_height" : 100,
    "padding" : 10,
    "start_it" : 0,
    "node_radius" : 2.5,
    "link_distance" : 10,
    "node_charge": -8,
    "edge_line_width" : 1,
    "font_size_in_px" : 14,
    "link_width" : 1,
    "d3_format_string": ".3f",