mighty.monitor.viz.VisdomMighty

class mighty.monitor.viz.VisdomMighty(env='main', offline=False)[source]

A Visdom server that updates measures in online fashion.

Parameters:
envstr, optional

Environment name. Default: “main”

offlinebool, optional

Online (False) or offline (True) mode. Default: False

Methods

__init__([env, offline])

audio([tensor, audiofile, win, env, opts])

This function plays audio.

bar(X[, Y, win, env, opts])

This function draws a regular, stacked, or grouped bar plot.

boxplot(X[, win, env, opts])

This function draws boxplots of the specified data.

check_connection([timeout_seconds])

This function returns a bool indicating whether or not the server is connected within some timeout.

clear_event_handlers(target)

close([win, env])

This function closes a specific window.

contour(X[, win, env, opts])

This function draws a contour plot.

delete_env(env)

This function deletes a specific environment.

dual_axis_lines([X, Y1, Y2, opts, win, env])

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

embeddings(features, labels[, data_getter, ...])

This function handles taking arbitrary features and compiling them into a set of embeddings.

fork_env(prev_eid, eid)

This function allows the user to fork environments.

get_env_list()

This function returns a list of all of the env names that are currently in the server.

get_window_data([win, env])

This function returns all the window data for a specified window in an environment.

graph(edges[, edgeLabels, nodeLabels, opts, ...])

This function draws interactive network graphs.

heatmap(X[, win, env, update, opts])

This function draws a heatmap.

histogram(X[, win, env, opts])

This function draws a histogram of the specified data.

image(img[, win, env, opts])

This function draws an img.

images(tensor[, nrow, padding, win, env, opts])

Given a 4D tensor of shape (B x C x H x W), or a list of images all of the same size, makes a grid of images of size (B / nrow, nrow).

line(Y[, X, win, env, opts, update, name])

This function draws a line plot.

line_update(y, opts[, name])

Appends y axis value to the plot.

log(text[, timestamp])

Log the text.

matplot(plot[, opts, env, win])

This function draws a Matplotlib plot.

mesh(X[, Y, win, env, opts])

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.

pie(X[, win, env, opts])

This function draws a pie chart based on the N tensor X.

plotlyplot(figure[, win, env])

This function draws a Plotly 'Figure' object.

properties(data[, win, env, opts])

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: - text: string - number: decimal number - button: button labeled with "value" - checkbox: boolean value rendered as a checkbox - select: multiple values select box - value: id of selected value (zero based) - values: list of possible values.

quiver(X, Y[, gridX, gridY, win, env, opts])

This function draws a quiver plot in which the direction and length of the arrows is determined by the NxM tensors X and Y.

register_event_handler(handler, target)

replay_log(log_filename)

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

save(envs)

This function allows the user to save envs that are alive on the Tornado server.

scatter(X[, Y, win, env, opts, update, name])

This function draws a 2D or 3D scatter plot.

set_window_data(data[, win, env])

This function sets all the window data for a specified window in an environment.

setup_polling()

setup_socket([polling])

stem(X[, Y, win, env, opts])

This function draws a stem plot.

sunburst(labels, parents[, values, win, ...])

surf(X[, win, env, opts])

This function draws a surface plot.

svg([svgstr, svgfile, win, env, opts])

This function draws an SVG object.

text(text[, win, env, opts, append])

This function prints text in a box.

update_window_opts(win, opts[, env])

This function allows pushing new options to an existing plot window without updating the content

video([tensor, dim, videofile, win, env, opts])

This function plays a video.

win_exists(win[, env])

This function returns a bool indicating whether or not a window exists on the server already.

win_hash(win[, env])

This function returns md5 hash of the contents of a window if it exists on the server.

Attributes

session

audio(tensor=None, audiofile=None, win=None, env=None, opts=None)

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:

  • opts.sample_frequency: sample frequency (integer > 0; default = 44100)

bar(X, Y=None, win=None, env=None, opts=None)

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 bar. If X contains M columns, the values corresponding to each row are either stacked or grouped (dependending 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:

  • opts.rownames: list containing x-axis labels

  • opts.stackedstack multiple columns in X
    • opts.legend : list containing legend labels

boxplot(X, win=None, env=None, opts=None)

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: - opts.legend: labels for each of the columns in X

check_connection(timeout_seconds=0)

This function returns a bool indicating whether or not the server is connected within some timeout. It waits for timeout_seconds before determining if the server responds.

close(win=None, env=None)

This function closes a specific window. Use win=None to close all windows in an env.

contour(X, win=None, env=None, opts=None)

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:

  • opts.colormap: colormap (string; default = ‘Viridis’)

  • opts.xmin : clip minimum value (number; default = X:min())

  • opts.xmax : clip maximum value (number; default = X:max())

delete_env(env)

This function deletes a specific environment.

dual_axis_lines(X=None, Y1=None, Y2=None, opts=None, win=None, env=None)

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:

  • opts.height : Height of the plot

  • opts.width : Width of the plot

  • opts.name_y1 : Axis name for Y1 plot

  • opts.name_y2 : Axis name for Y2 plot

  • opts.title : Title of the plot

  • opts.color_title_y1 : Color of the Y1 axis Title

  • opts.color_tick_y1 : Color of the Y1 axis Ticks

  • opts.color_title_y2 : Color of the Y2 axis Title

  • opts.color_tick_y2 : Color of the Y2 axis Ticks

  • opts.side : Placement of y2 tick. Options ‘right’ or left.

  • opts.showlegend : Display legends (boolean values)

  • opts.top : Set the top margin of the plot

  • opts.bottom : Set the bottom margin of the plot

  • opts.right : Set the right margin of the plot

  • opts.left : Set the left margin of the plot

embeddings(features, labels, data_getter=None, data_type=None, win=None, env=None, opts=None)

This function handles taking arbitrary features and compiling them into a set of embeddings. It then leverages the _register_embeddings to actually run the visualization.

We assume that there are no more than 10 unique labels at the moment, in the future we can include a colormap in opts for other cases

If you want to provide a preview on hover for your data, you can supply a getting function for data_getter and a data_type. At the moment the only data_type supported is ‘html’, which means your data_getter takes in an index into features that is currently selected and returns the html for what you’d like to display.

fork_env(prev_eid, eid)

This function allows the user to fork environments.

get_env_list()

This function returns a list of all of the env names that are currently in the server.

get_window_data(win=None, env=None)

This function returns all the window data for a specified window in an environment. Use win=None to get all the windows in the given environment. Env defaults to main

graph(edges, edgeLabels=None, nodeLabels=None, opts={}, env=None, win=None)

This function draws interactive network graphs. It takes list of edges as one of the arguments. The user can also provide custom edge Labels and node Labels in edgeLabels and nodeLabels respectively. Along with that we have different parameters in opts for making it more user friendly.

Args:
edgeslist, required

A list of graph edges in one of the following formats (source, destination)

edgeLabelslist, optional

list of custom edge-labels. length should be equal to that of “edges”

nodeLabelslist, optional

list of custom node-labels. length should be equal to number of nodes and sequence must be in ascending order.

optsdict, optional
  • directed : directed (True) or undirected (False) graph; False by default

  • showVertexLabels : boolean , if True displays vertex labels else hides the label; “True” by default

  • showEdgeLabels : boolean , if True displays edge labels else hides the label; “False” by default

  • scheme : {“same”, “different”} nodes with “same” or “diffent” colors; “same” by default

  • height : height of the Pane

  • width : width of the Pane

heatmap(X, win=None, env=None, update=None, opts=None)

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 saved to a window given by win. Use the value ‘appendRow’ to append data row-wise, ‘appendRow’ to append data row-wise, ‘appendColumn’ to append data column-wise, ‘prependRow’ to prepend data row-wise, ‘prependColumn’ to append data column-wise, ‘replace’ to use new data, and ‘remove’ to delete the plot. Using update=appendRow or update=’appendColumn’ will create a plot if it doesn’t exist and append to the existing plot otherwise.

The following opts are supported:

  • opts.colormap: colormap (string; default = ‘Viridis’)

  • opts.xmin : clip minimum value (number; default = X:min())

  • opts.xmax : clip maximum value (number; default = X:max())

  • opts.columnnames: list containing x-axis labels

  • opts.rownames: list containing y-axis labels

  • opts.nancolor: if not None, color for plotting nan

    (string; default = None)

histogram(X, win=None, env=None, opts=None)

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:

  • opts.numbins: number of bins (number; default = 30)

image(img, win=None, env=None, opts=None)

This function draws an img. It takes as input an CxHxW or HxW tensor img that contains the image. The array values can be float in [0,1] or uint8 in [0, 255].

images(tensor, nrow=8, padding=2, win=None, env=None, opts=None)

Given a 4D tensor of shape (B x C x H x W), or a list of images all of the same size, makes a grid of images of size (B / nrow, nrow).

This is a modified from make_grid() https://github.com/pytorch/vision/blob/master/torchvision/utils.py

line(Y, X=None, win=None, env=None, opts=None, update=None, name=None)

This function draws a line plot. It takes in 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 line. Use ‘append’ to append data, ‘replace’ to use new data, and ‘remove’ to delete the trace that is specified in 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). Using update=’append’ will create a plot if it doesn’t exist and append to the existing plot otherwise.

The following opts are supported:

  • opts.fillarea : fill area below line (boolean)

  • opts.markers : show markers (boolean; default = false)

  • opts.markersymbol: marker symbol (string; default = ‘dot’)

  • opts.markersize : marker size (number; default = ‘10’)

  • opts.linecolor : line colors (np.array; default = None)

  • opts.dash : line dash type (np.array; default = None)

  • opts.legend : list or tuple containing legend names

If update is specified, the figure will be updated without creating a new plot – this can be used for efficient updating.

line_update(y, opts, name=None)[source]

Appends y axis value to the plot. The x axis value will be extracted from the global timer.

Parameters:
yfloat or list of float or torch.Tensor

The Y axis value.

optsdict

Visdom plot opts.

namestr or None, optional

The label name of this plot. Used when a plot has a legend. Default: None

log(text, timestamp=True)[source]

Log the text.

Parameters:
textstr

Text

timestampbool, optional

Prepend date timestamp (True) or not. Default: True

matplot(plot, opts=None, env=None, win=None)

This function draws a Matplotlib plot. The function supports one plot-specific option: resizable. When set to True the plot is resized with the pane. You need beautifulsoup4 and lxml packages installed to use this option.

mesh(X, Y=None, win=None, env=None, opts=None)

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:

  • opts.color: color (string)

  • opts.opacity: opacity of polygons (number between 0 and 1)

pie(X, win=None, env=None, opts=None)

This function draws a pie chart based on the N tensor X.

The following opts are supported:

  • opts.legend: list containing legend names

plotlyplot(figure, win=None, env=None)

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.

properties(data, win=None, env=None, opts=None)

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:

  • text: string

  • number: decimal number

  • button: button labeled with “value”

  • checkbox: boolean value rendered as a checkbox

  • select: multiple values select box
    • value: id of selected value (zero based)

    • values: list of possible values

Callback are called on property value update:
  • event_type: “PropertyUpdate”

  • propertyId: position in the properties list

  • value: new value

No specific opts are currently supported.

quiver(X, Y, gridX=None, gridY=None, win=None, env=None, opts=None)

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:

  • opts.normalize: length of longest arrows (number)

  • opts.arrowheads: show arrow heads (boolean; default = true)

replay_log(log_filename)

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

save(envs)

This function allows the user to save envs that are alive on the Tornado server. The envs can be specified as a list of env ids.

scatter(X, Y=None, win=None, env=None, opts=None, update=None, name=None)

This function draws a 2D or 3D scatter plot. It takes in 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, and ‘remove’ to delete the trace that is specified in 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). Using update=’append’ will create a plot if it doesn’t exist and append to the existing plot otherwise.

The following opts are supported:

  • opts.markersymbol : marker symbol (string; default = ‘dot’)

  • opts.markersize : marker size (number; default = ‘10’)

  • opts.markercolor : marker color (np.array; default = None)

  • opts.markerborderwidth: marker border line width (float; default = 0.5)

  • opts.dash : dash type (np.array; default = ‘solid’`)

  • opts.textlabels : text label for each point (list: default = None)

  • opts.legend : list or tuple containing legend names

set_window_data(data, win=None, env=None)

This function sets all the window data for a specified window in an environment. Use win=None to set the data for all the windows in the given environment. Env defaults to main. data should be as returned from get_window_data.

stem(X, Y=None, win=None, env=None, opts=None)

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 given 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:

  • opts.colormap: colormap (string; default = ‘Viridis’)

  • opts.legend : list containing legend names

surf(X, win=None, env=None, opts=None)

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:

  • opts.colormap: colormap (string; default = ‘Viridis’)

  • opts.xmin : clip minimum value (number; default = X:min())

  • opts.xmax : clip maximum value (number; default = X:max())

svg(svgstr=None, svgfile=None, win=None, env=None, opts=None)

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

text(text, win=None, env=None, opts=None, append=False)

This function prints text in a box. It takes as input an text string. No specific opts are currently supported.

update_window_opts(win, opts, env=None)

This function allows pushing new options to an existing plot window without updating the content

video(tensor=None, dim='LxHxWxC', videofile=None, win=None, env=None, opts=None)

This function plays a video. It takes as input the filename of the video videofile or a LxHxWxC or LxCxHxW-sized tensor containing all the frames of the video as input, as specified in dim. The color channels must be in BGR order.

Internally, video encoding is done with [PyAV] (http://docs.mikeboers.com/pyav/develop/installation.html). The import is deferred as it’s a dependency most Visdom users won’t encounter.

The function does not support any plot-specific opts. The following video opts are supported:

  • opts.fps: FPS for the video (integer > 0; default = 25)

  • opts.autoplay: whether to autoplay the video when ready (boolean; default = false)

  • opts.loop: whether to loop the video (boolean; default = false)

win_exists(win, env=None)

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

win_hash(win, env=None)

This function returns md5 hash of the contents of a window if it exists on the server. Returns None, otherwise