Home

Awesome

<h3 align="center"> <br/> <img src="https://user-images.githubusercontent.com/19650074/198746195-574bb828-026f-41cb-82a9-250fcbc4e090.png" width="300" alt="Logo"/><br/><br/> Creating, organizing & sharing visualizations of live, rich data. Supports <a href="https://pypi.org/project/visdom/">Python</a>. </h3> <p align="center"> Jump To: <a href="#setup">Setup</a>, <a href="#usage">Usage</a>, <a href="#api">API</a>, <a href="#customizing-visdom">Customizing</a>, <a href="#contributing">Contributing</a>, <a href="#license">License</a> </p> <p align="center"> <a href="https://github.com/fossasia/visdom/releases"><img src="https://img.shields.io/github/v/release/fossasia/visdom?colorA=363a4f&colorB=a6da95&style=for-the-badge"/></a> <a href="https://pypi.org/project/visdom"><img src="https://img.shields.io/pypi/dd/visdom?colorA=363a4f&colorB=156df1&style=for-the-badge"></a> <a href="https://github.com/fossasia/visdom/commits"><img src="https://img.shields.io/github/commit-activity/m/fossasia/visdom?colorA=363a4f&colorB=0099ff&style=for-the-badge"/></a> <a href="https://github.com/fossasia/visdom/contributors"><img src="https://img.shields.io/github/contributors/fossasia/visdom?colorA=363a4f&colorB=60b9f4&style=for-the-badge"/></a> </p> <p align="center"> Visdom aims to facilitate visualization of (remote) data with an emphasis on supporting scientific experimentation.<br/> Broadcast visualizations of plots, images, and text for yourself and your collaborators. Organize your visualization space programmatically or through the UI to create dashboards for live data, inspect results of experiments, or debug experimental code. </p> <p align="center"> <img src="https://user-images.githubusercontent.com/19650074/198747904-7a8a580f-851a-45fb-8f45-94e54a910ee2.png"/> </p> <p align="center"> <img width="49.5%" src="https://user-images.githubusercontent.com/19650074/198748177-c973f387-c392-4f6e-9e3d-27dfe578eb59.gif"/> <img width="49.5%" src="https://user-images.githubusercontent.com/19650074/198748189-917091b6-95c4-4415-b965-ba3e7e81e1f8.png"/> </p>

Concepts

Visdom has a simple set of features that can be composed for various use-cases.

<details> <summary><b>Windows</b></summary> <p align="center"> <img width=500 align="center" src="https://user-images.githubusercontent.com/19650074/198821065-6666cb22-d34a-4839-ae19-f6f6a4a1bae4.png"/> </p>

The UI begins as a blank slate – you can populate it with plots, images, and text. These appear in windows that you can drag, drop, resize, and destroy. The windows live in envs and the state of envs is stored across sessions. You can download the content of windows – including your plots in svg.

Tip: You can use the zoom of your browser to adjust the scale of the UI.

</details> <details> <summary><b>Callbacks</b></summary>

The python Visdom implementation supports callbacks on a window. The demo shows an example of this in the form of an editable text pad. The functionality of these callbacks allows the Visdom object to receive and react to events that happen in the frontend.

You can subscribe a window to events by adding a function to the event handlers dict for the window id you want to subscribe by calling viz.register_event_handler(handler, win_id) with your handler and the window id. Multiple handlers can be registered to the same window. You can remove all event handlers from a window using viz.clear_event_handlers(win_id). When an event occurs to that window, your callbacks will be called on a dict containing:

Additional parameters are defined below.

Right now the following callback events are supported:

  1. Close - Triggers when a window is closed. Returns a dict with only the aforementioned fields.
  2. KeyPress - Triggers when a key is pressed. Contains additional parameters:
    • key - A string representation of the key pressed (applying state modifiers such as SHIFT)
    • key_code - The javascript event keycode for the pressed key (no modifiers)
  3. PropertyUpdate - Triggers when a property is updated in Property pane
    • propertyId - Position in properties list
    • value - New property value
  4. Click - Triggers when Image pane is clicked on, has a parameter:
    • image_coord - dictionary with the fields x and y for the click coordinates in the coordinate frame of the possibly zoomed/panned image (not the enclosing pane).
</details> <details> <summary><b>Editable Plot Parameters</b></summary> Use the top-right *edit*-Button to inspect all parameters used for plot in the respective window. The visdom client supports dynamic change of plot parameters as well. Just change one of the listed parameters, the plot will be altered on-the-fly. Click the button again to close the property list. <p align="center"><img align="center" src="https://user-images.githubusercontent.com/19650074/156751970-0915757d-8bf0-4a6d-a510-1d34a918e47a.gif" width="400" /></p> </details> <details> <summary><b>Environments</b></summary> <p align="center"><img align="center" src="https://user-images.githubusercontent.com/19650074/198821281-ea1cea1a-66c3-495e-be52-cd0f1a3300f7.png" width="300" /></p>

You can partition your visualization space with envs. By default, every user will have an env called main. New envs can be created in the UI or programmatically. The state of envs is chronically saved. Environments are able to keep entirely different pools of plots.

You can access a specific env via url: http://localhost.com:8097/env/main. If your server is hosted, you can share this url so others can see your visualizations too.

Environments are automatically hierarchically organized by the first _.

Selecting Environments

<p align="center"><img align="center" src="https://user-images.githubusercontent.com/19650074/198821299-6602d557-7a02-4b9f-b1d5-d57615cdc15c.png" width="300" /></p>

From the main page it is possible to toggle between different environments using the environment selector. Selecting a new environment will query the server for the plots that exist in that environment. The environment selector allows for searching and filtering for the new enironment.

Comparing Environments

From the main page it is possible to compare different environments using the environment selector. Selecting multiple environments in the check box will query the server for the plots with the same titles in all environments and plot them in a single plot. An additional compare legend pane is created with a number corresponding to each selected environment. Individual plots are updated with legends corresponding to "x_name" where x is a number corresponding with the compare legend pane and name is the original name in the legend.

Note: The compare envs view is not robust to high throughput data, as the server is responsible for generating the compared content. Do not compare an environment that is receiving a high quantity of updates on any plot, as every update will request regenerating the comparison. If you need to compare two plots that are receiving high quantities of data, have them share the same window on a singular env.

Clearing Environments

You can use the eraser button to remove all of the current contents of an environment. This closes the plot windows for that environment but keeps the empty environment for new plots.

Managing Environments

<p align="center"><img align="center" src="https://user-images.githubusercontent.com/19650074/198821309-4c6449fd-978a-462a-aa35-e59d872b61bd.png" width="400" /></p>

Pressing the folder icon opens a dialog that allows you to fork or force save the current environment, or delete any of your existing environments. Use of this feature is fully described in the State section.

Env Files: Your envs are loaded upon request by the user, by default from $HOME/.visdom/. Custom paths can be passed as a cmd-line argument. Envs are removed by using the delete button or by deleting the corresponding .json file from the env dir. In case you want the server to pre-load all files into cache, use the flag -eager_data_loading.

</details> <details> <summary><b>State</b></summary>

Once you've created a few visualizations, state is maintained. The server automatically caches your visualizations -- if you reload the page, your visualizations reappear.

<p align="center"><img align="center" src="https://user-images.githubusercontent.com/19650074/198821344-cb8c424e-455c-4249-b3b4-5554309a5ec7.gif" width="400" /></p>

Tip: Fork an environment before you begin to make edits to ensure that your changes are saved seperately.

Filter

You can use the filter to dynamically sift through windows present in an env -- just provide a regular expression with which to match titles of window you want to show. This can be helpful in use cases involving an env with many windows e.g. when systematically checking experimental results.

<p align="center"><img align="center" src="https://user-images.githubusercontent.com/19650074/198821379-eeebd8a2-bcab-407a-b47f-9b2d0290c23e.png" width="300" /></p>

Note: If you have saved your current view, the view will be restored after clearing the filter.

<p align="center"><img align="center" src="https://user-images.githubusercontent.com/19650074/198821402-4702611e-1038-4093-8cd5-9c8120444211.gif" width="500" /></p>

Views

<p align="center"><img align="center" src="https://user-images.githubusercontent.com/19650074/198821420-458c863b-c304-4d10-8906-0cc2f0c20241.png" width="300" /></p>

It is possible to manage the views simply by dragging the tops of windows around, however additional features exist to keep views organized and save common views. View management can be useful for saving and switching between multiple common organizations of your windows.

Saving/Deleting Views

Using the folder icon, a dialog window opens where views can be forked in the same way that envs can be. Saving a view will retain the position and sizes of all of the windows in a given environment. Views are saved in $HOME/.visdom/view/layouts.json in the visdom filepath.

Note: Saved views are static, and editing a saved view copies that view over to the current view where editing can occur.

Re-Packing

Using the repack icon (9 boxes), visdom will attempt to pack your windows in a way that they best fit while retaining row/column ordering.

Note: Due to the reliance on row/column ordering and ReactGridLayout the final layout might be slightly different than what might be expected. We're working on improving that experience or providing alternatives that give more fine-tuned control.

Reloading Views

<p align="center"><img align="center" src="https://user-images.githubusercontent.com/19650074/198821436-6c7957b5-dd67-4afc-9fc3-4bf074137022.gif" width="600" /></p>

Using the view dropdown it is possible to select previously saved views, restoring the locations and sizes of all of the windows within the current environment to the places they were when that view was saved last.

</details>

Setup

Python and web clients come bundled with the python server.

Install from pip

> pip install visdom

Install from source

> pip install git+https://github.com/fossasia/visdom

Usage

Start the server (probably in a screen or tmux) from the command line:

> visdom

Visdom now can be accessed by going to http://localhost:8097 in your browser, or your own host address if specified.

The visdom command is equivalent to running python -m visdom.server.

If the above does not work, try using an SSH tunnel to your server by adding the following line to your local ~/.ssh/config: LocalForward 127.0.0.1:8097 127.0.0.1:8097.

Command Line Options

The following options can be provided to the server:

  1. -port : The port to run the server on.
  2. -hostname : The hostname to run the server on.
  3. -base_url : The base server url (default = /).
  4. -env_path : The path to the serialized session to reload.
  5. -logging_level : Logging level (default = INFO). Accepts both standard text and numeric logging values.
  6. -readonly : Flag to start server in readonly mode.
  7. -enable_login : Flag to setup authentication for the sever, requiring a username and password to login.
  8. -force_new_cookie : Flag to reset the secure cookie used by the server, invalidating current login cookies. Requires -enable_login.
  9. -bind_local : Flag to make the server accessible only from localhost.
  10. -eager_data_loading : By default visdom loads environments lazily upon user request. Setting this flag lets visdom pre-fetch all environments upon startup.

When -enable_login flag is provided, the server asks user to input credentials using terminal prompt. Alternatively, you can setup VISDOM_USE_ENV_CREDENTIALS env variable, and then provide your username and password via VISDOM_USERNAME and VISDOM_PASSWORD env variables without manually interacting with the terminal. This setup is useful in case if you would like to launch visdom server from bash script, or from Jupyter notebook.

VISDOM_USERNAME=username
VISDOM_PASSWORD=password
VISDOM_USE_ENV_CREDENTIALS=1 visdom -enable_login

You can also use VISDOM_COOKIE variable to provide cookies value if the cookie file wasn't generated, or the flag -force_new_cookie was set.

Python example

import visdom
import numpy as np
vis = visdom.Visdom()
vis.text('Hello, world!')
vis.image(np.ones((3, 10, 10)))

Demos

If you have cloned this repository, you can run our demo showcase.

python example/demo.py

API

For a quick introduction into the capabilities of visdom, have a look at the example directory, or read the details below.

Visdom Arguments (Python only)

The python visdom client takes a few options:

Other options are either currently unused (endpoint, ipv6) or used for internal functionality.

Basics

Visdom offers the following basic visualization functions:

Plotting

We have wrapped several common plot types to make creating basic visualizations easily. These visualizations are powered by Plotly.

The following API is currently supported:

Generic Plots

Note that the server API adheres to the Plotly convention of data and layout objects, such that you can produce your own arbitrary Plotly visualizations:

import visdom
vis = visdom.Visdom()

trace = dict(x=[1, 2, 3], y=[4, 5, 6], mode="markers+lines", type='custom',
             marker={'color': 'red', 'symbol': 104, 'size': "10"},
             text=["one", "two", "three"], name='1st Trace')
layout = dict(title="First Plot", xaxis={'title': 'x1'}, yaxis={'title': 'x2'})

vis._send({'data': [trace], 'layout': layout, 'win': 'mywin'})

Others

Details

<img src="https://user-images.githubusercontent.com/19650074/198747904-7a8a580f-851a-45fb-8f45-94e54a910ee2.png"/>

Basics

vis.image

This function draws an img. It takes as input an CxHxW tensor img that contains the image.

The following opts are supported:

Note You can use alt on an image pane to view the x/y coordinates of the cursor. You can also ctrl-scroll to zoom, alt scroll to pan vertically, and alt-shift scroll to pan horizontally. Double click inside the pane to restore the image to default.

vis.images

This function draws a list of images. It takes an input B x C x H x W tensor or a list of images all of the same size. It makes a grid of images of size (B / nrow, nrow).

The following arguments and opts are supported:

vis.text

This function prints text in a box. You can use this to embed arbitrary HTML. It takes as input a text string. No specific opts are currently supported.

vis.properties

This function shows editable properties in a pane. Properties are expected to be a List of Dicts e.g.:

    properties = [
        {'type': 'text', 'name': 'Text input', 'value': 'initial'},
        {'type': 'number', 'name': 'Number input', 'value': '12'},
        {'type': 'button', 'name': 'Button', 'value': 'Start'},
        {'type': 'checkbox', 'name': 'Checkbox', 'value': True},
        {'type': 'select', 'name': 'Select', 'value': 1, 'values': ['Red', 'Green', 'Blue']},
    ]

Supported types:

Callback are called on property value update:

No specific opts are currently supported.

vis.audio

This function plays audio. It takes as input the filename of the audio file or an N tensor containing the waveform (use an Nx2 matrix for stereo audio). The function does not support any plot-specific opts.

The following opts are supported:

Known issue: Visdom uses scipy to convert tensor inputs to wave files. Some versions of Chrome are known not to play these wave files (Firefox and Safari work fine).

vis.video

This function plays a video. It takes as input the filename of the video videofile or a LxHxWxC-sized tensor containing all the frames of the video as input. The function does not support any plot-specific opts.

The following opts are supported:

Note: Using tensor input requires that ffmpeg is installed and working. Your ability to play video may depend on the browser you use: your browser has to support the Theano codec in an OGG container (Chrome supports this).

vis.svg

This function draws an SVG object. It takes as input a SVG string svgstr or the name of an SVG file svgfile. The function does not support any specific opts.

vis.matplot

This function draws a Matplotlib plot. The function supports one plot-specific option: resizable.

Note When set to True the plot is resized with the pane. You need beautifulsoup4 and lxml packages installed to use this option.

Note: matplot is not rendered using the same backend as plotly plots, and is somewhat less efficient. Using too many matplot windows may degrade visdom performance.

vis.plotlyplot

This function draws a Plotly Figure object. It does not explicitly take options as it assumes you have already explicitly configured the figure's layout.

Note You must have the plotly Python package installed to use this function. It can typically be installed by running pip install plotly.

vis.embeddings

This function visualizes a collection of features using the Barnes-Hut t-SNE algorithm.

The function accepts the following arguments:

We currently assume that there are no more than 10 unique labels, in the future we hope to provide a colormap in opts for other cases.

From the UI you can also draw a lasso around a subset of features. This will rerun the t-SNE visualization on the selected subset.

vis.save

This function saves the envs that are alive on the visdom server. It takes input a list of env ids to be saved.

Plotting

Further details on the wrapped plotting functions are given below.

The exact inputs into the plotting functions vary, although most of them take as input a tensor X than contains the data and an (optional) tensor Y that contains optional data variables (such as labels or timestamps). All plotting functions take as input an optional win that can be used to plot into a specific window; each plotting function also returns the win of the window it plotted in. One can also specify the env to which the visualization should be added.

vis.scatter

This function draws a 2D or 3D scatter plot. It takes as input an Nx2 or Nx3 tensor X that specifies the locations of the N points in the scatter plot. An optional N tensor Y containing discrete labels that range between 1 and K can be specified as well -- the labels will be reflected in the colors of the markers.

update can be used to efficiently update the data of an existing plot. Use 'append' to append data, 'replace' to use new data, or 'remove' to remove the trace specified by name. Using update='append' will create a plot if it doesn't exist and append to the existing plot otherwise. If updating a single trace, use name to specify the name of the trace to be updated. Update data that is all NaN is ignored (can be used for masking update).

The following opts are supported:

opts.markercolor is a Tensor with Integer values. The tensor can be of size N or N x 3 or K or K x 3.

vis.sunburst

This function draws a sunburst chart. It takes two inputs: parents and labels array. values from parents array is used as parents object, like it define above which sector should the this sector shown. values from labels array is used to define sector's label or you can say name. keep in mind that lenght of array parents and labels should be equal. There is a third array that you can pass to which is value, it is use to show a value on hovering over a sector, it is optional argument, but if you are passing it then keep in mind lenght of values should be equal to parents or labels.

Following opts are currently supported:

vis.line

This function draws a line plot. It takes as input an N or NxM tensor Y that specifies the values of the M lines (that connect N points) to plot. It also takes an optional X tensor that specifies the corresponding x-axis values; X can be an N tensor (in which case all lines will share the same x-axis values) or have the same size as Y.

update can be used to efficiently update the data of an existing plot. Use 'append' to append data, 'replace' to use new data, or 'remove' to remove the trace specified by name. If updating a single trace, use name to specify the name of the trace to be updated. Update data that is all NaN is ignored (can be used for masking update).

Smoothing: Line plots can be smoothened using Savitzky-Golay filtering. This feature can be enabled by clicking the ~-symbol in the top right corner of a window that contains a line plot.

Demo of interactive smoothing.

The following opts are supported:

vis.stem

This function draws a stem plot. It takes as input an N or NxM tensor X that specifies the values of the N points in the M time series. An optional N or NxM tensor Y containing timestamps can be specified as well; if Y is an N tensor then all M time series are assumed to have the same timestamps.

The following opts are supported:

vis.heatmap

This function draws a heatmap. It takes as input an NxM tensor X that specifies the value at each location in the heatmap.

update can be used to efficiently update the data of an existing plot. Use 'appendRow' to append data row-wise, 'appendColumn' to append data column-wise, 'prependRow' to prepend data row-wise, 'prependColumn' to prepend data column-wise, 'replace' to use new data, or 'remove' to remove the plot specified by win.

The following opts are supported:

vis.bar

This function draws a regular, stacked, or grouped bar plot. It takes as input an N or NxM tensor X that specifies the height of each of the bars. If X contains M columns, the values corresponding to each row are either stacked or grouped (depending on how opts.stacked is set). In addition to X, an (optional) N tensor Y can be specified that contains the corresponding x-axis values.

The following plot-specific opts are currently supported:

vis.histogram

This function draws a histogram of the specified data. It takes as input an N tensor X that specifies the data of which to construct the histogram.

The following plot-specific opts are currently supported:

vis.boxplot

This function draws boxplots of the specified data. It takes as input an N or an NxM tensor X that specifies the N data values of which to construct the M boxplots.

The following plot-specific opts are currently supported:

vis.surf

This function draws a surface plot. It takes as input an NxM tensor X that specifies the value at each location in the surface plot.

The following opts are supported:

vis.contour

This function draws a contour plot. It takes as input an NxM tensor X that specifies the value at each location in the contour plot.

The following opts are supported:

vis.quiver

This function draws a quiver plot in which the direction and length of the arrows is determined by the NxM tensors X and Y. Two optional NxM tensors gridX and gridY can be provided that specify the offsets of the arrows; by default, the arrows will be done on a regular grid.

The following opts are supported:

vis.mesh

This function draws a mesh plot from a set of vertices defined in an Nx2 or Nx3 matrix X, and polygons defined in an optional Mx2 or Mx3 matrix Y.

The following opts are supported:

vis.dual_axis_lines

This function will create a line plot using plotly with different Y-Axis.

X = A numpy array of the range.

Y1 = A numpy array of the same count as X.

Y2 = A numpy array of the same count as X.

The following opts are supported:

This is the image of the output:

<p align="center"><img align="center" src="https://user-images.githubusercontent.com/19650074/198822367-666cc42e-4354-4a7a-8dd3-d8ff143f885d.gif" width="400" /></p>

Network Graph

This function draws a graph, in which the nodes and edges are taken from a 2-D matrix of size [,2] where each row contains a source and destination node value. The numeric value used to define nodes should be strictly between (0 to n-1), where n is the number of nodes.

There are two optional arguments :

The following opts are supported:

Customizing plots

The plotting functions take an optional opts table as input that can be used to change (generic or plot-specific) properties of the plots.

All input arguments are specified in a single table; the input arguments are matches based on the keys they have in the input table.

The following opts are generic in the sense that they are the same for all visualizations (except plot.image, plot.text, plot.video, and plot.audio):

opts are passed as dictionary in python scripts.You can pass opts like:

opts=dict(title="my title", xlabel="x axis",ylabel="y axis")

OR

opts={"title":"my title", "xlabel":"x axis","ylabel":"y axis"}

The other options are visualization-specific, and are described in the documentation of the functions.

Others

vis.close

This function closes a specific window. It takes input window id win and environment id eid. Use win as None to close all windows in an environment.

vis.delete_env

This function deletes a specified env entirely. It takes env id eid as input.

Note: delete_env is deletes all data for an environment and is IRREVERSIBLE. Do not use unless you absolutely want to remove an environment.

vis.fork_env

This function forks an environment, similiar to the UI feature.

Arguments:

Note: fork_env an exception will occur if an env that doesn't exist is forked.

vis.win_exists

This function returns a bool indicating whether or not a window win exists on the server already. Returns None if something went wrong.

Optional arguments:

vis.get_env_list

This function returns a list of all of the environments on the server at the time of calling. It takes no arguments.

vis.get_window_data

This function returns the window data for the given window. Returns data for all windows in an env if win is None.

Arguments:

vis.check_connection

This function returns a bool indicating whether or not the server is connected. It accepts an optional argument timeout_seconds for a number of seconds to wait for the server to come up.

vis.replay_log

This function takes the contents of a visdom log and replays them to the current server to restore a state or handle any missing entries.

Arguments:

Customizing Visdom

The user config directory for visdom is

By placing a style.css in you user config directory, visdom will serve the customized css file along with the default style-file. In addition, it is also possible to create a project-specific file; just place the file style.css in your env_path.

License

visdom is Apache 2.0 licensed, as found in the LICENSE file.

Note on Lua Torch Support

Support for Lua Torch was deprecated following v0.1.8.4. If you'd like to use torch support, you'll need to download that release. You can follow the usage instructions there, but it is no longer officially supported.

Contributing

See guidelines for contributing here.

Acknowledgments

Visdom was inspired by tools like display and relies on Plotly as a plotting front-end.