Interactive wxmplot displays

The wxmplot Overview describes the main features of wxmplot and shows how wxmplot plotting functions give a richer level of customization and interactivity to the end user than is available from the standard matplotlib.pyplot. Here, the emphasis is on the immediacy of the interactivity of the data displays especially when used from interactive sessions. An important feature of the plot(), imshow() and other functions of the interactive module is that they display their results immediately, without having to execute a show() method to render the display. For interactive work from the Python (or one of the Jupyter consoles or notebook) prompt, the displayed windows do not block the Python session. This means that not only can you zoom in, change themes, etc from the Plot window, you can can also easily plot other functions or data, either on the same window or in a new top-level plotting window.

While wxmplot provides plot(), imshow() and other functions that are roughly equivalent to the functions from matplotlib.pyplot, the functions are here not exact drop-in replacements for the pyplot functions. For one thing, there are many missing plot types and functions. For another, the syntax for specifying options is different. For example, wxmplot prefers a long list of keyword arguments to plot() over a series of separate function calls.

The functions in the interactive are described in detail below.

Plotting in an interactive session

As an example using wxmplot.interactive in a Jupyter-qtconsole session might look like this:

Jupyter QtConsole 4.5.4
Python 3.7.4 (default, Aug 13 2019, 20:35:49)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.7.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import numpy as np

In [2]: import wxmplot.interactive as wi

In [3]: x = np.linspace(0, 20, 101)

In [4]: wi.plot(x, np.sin(x), xlabel='t (sec)')
Out[4]: <wxmplot.interactive.PlotDisplay at 0x10db88678>

In [5]:

At this point a plot like this will be displayed:


As with using %matplotlib notebook in a Jupyter notebook, the wxmplot display can be zoomed in and out, but as shown in wxmplot Overview, it can also be configured and updated in many more ways.

For example, from the Plot Configuration window we could change the theme to ‘Seaborn’ and set the label for this trace to be ‘sine’. Then from the Jupyter console we can continue:

In [5]: wi.plot(x, np.cos(1.5*x), label='cosine', show_legend=True)
Out[5]: <wxmplot.interactive.PlotDisplay at 0x10db88678>

In [6]:

which will now show:


which is again a fully interactive and configurable display. For example, with the legend displayed, clicking on any of the labels in the legend will toggle the display of that curve. If we want to clear the data and plot something new, we might do something like:

In [6]: wi.plot(x, x*np.log(x+1), label='xlogx', new=True)
Out[6]: <wxmplot.interactive.PlotDisplay at 0x10db88678>

In [7]:

We can also place a text string, arrow, horizontal, or vertical line on the plot, as with:

In [7]: wi.plot_text('hello!', 9.1, 0.87)

In [8]:

and so forth.

If we wanted to bring up a second 2D Line Plot window, we can use the win=2 option:

In [8]: wi.plot(x, np.sin(x)*np.exp(-x/8) , win=2, theme='ggplot')
Out[8]: <wxmplot.interactive.PlotDisplay at 0x110b2fb88>

In [9]:

and then control which of the displays any additional plot functions use by passing the win option to the plotting functions.

The immediacy of the rendering and the ability to customize the plots makes these plotting functions well-suited for exploratory displays of data.

Using the interactive functions from a script

When using the interactive functions by running a script in a non-interactive way, the display will still appear. It does not block further execution of the script and the display does not disappear when the script is complete. Instead, the plots and images will remain displayed and fully operational until all windows have been closed or until the running script is explicitly closed with Crtl-C. That means that you can add wi.plot() and wi.imshow() to your short- or long-running scripts and the plots will be displayed until you no longer want to use them.

Displaying images with imshow() and contour()

imshow(map, ...)

Display an 2-D array of intensities as a false-color map

  • map (ndarray) – map array data (see Note 1)

  • y (array-like) – values for pixels along vertical direction

  • x (array-like) – values for pixels along horizontal direction

  • colormap (str) – name of colormap to apply

  • win (int) – index of Image Window (1 to %d)

  • size (tuple) – width, height in pixels of Image Window

  • wintitle (str) – text for Window title [Image Window N]

  • xlabel (str) – label for horizontal axis [‘X’]

  • ylabel (str) – label for horizontal axis [‘Y’]

  • style (str) – display style (‘image’ or ‘contour’) [‘image’]

  • nlevels (int) – number of levels for contour

  • contour_labels (bool) – whether to show contour labels [True]

  • show_axis (bool) – whether to shos Axis [False]

  • contrast_level (float) – percent level for contrast [0]


img, an ImageFrame


  1. the map data can either be a 2d array (shape NY, NX) for single-color map or (NY, NX, 3) array for an RGB map

contour(map, ...)

Display an 2-D array of intensities as a contour plot


This is equivalent to imshow(map, …, style=’contour’)

Functions for working with the interactive windows


set plotting theme by name with a theme name


theme (str) – name of theme




  1. Example themese are:’light’, ‘dark’, ‘matplotlib’, ‘seaborn’, ‘ggplot’, ‘bmh’, ‘fivethirtyeight’.

  2. See available_themes() for the list of available themes.


list of available theme


list of theme names.


As of this writing, the list is:

‘light’, ‘dark’, ‘matplotlib’, ‘seaborn’, ‘ggplot’, ‘bmh’, ‘fivethirtyeight’, ‘grayscale’, ‘dark_background’, ‘tableau-colorblind10’, ‘seaborn-bright’, ‘seaborn-colorblind’, ‘seaborn-dark’, ‘seaborn-darkgrid’, ‘seaborn-dark-palette’, ‘seaborn-deep’, ‘seaborn-notebook’, ‘seaborn-muted’, ‘seaborn-pastel’, ‘seaborn-paper’, ‘seaborn-poster’, ‘seaborn-talk’, ‘seaborn-ticks’, ‘seaborn-white’, ‘seaborn-whitegrid’, ‘Solarize_Light2’

get_wxapp(redirect=False, clearSigInt=True)

get the wx App

  • redirect (bool) – whether to redirect output that would otherwise be written to the Console [False]

  • clearSigInt (bool) – whether to clear interrupts of Ctrl-C [True]


a wx.App instance

get_plot_window(win=1, size=None, wintitle=None, theme=None)

return a plot display

  • win (int) – index of Plot Window (1 to 100)

  • size (tuple) – width, height in pixels of Plot Window

  • wintitle (str) – text for Window title [Plot Window N]

  • theme (str) – theme for Plot Window [‘light’]


diplay, a wxmplot PlotFrame.


this will either return the existing PlotFrame for the window index or create a new one.

The returned wx.PlotFrame will have the heirarchy of attributes described in the table below. This allows access to the underlying matplotlib Axes and Canvas objects.

Table of PlotFrame attributes


object type


wxmplot.PlotPanel, a wx.Panel









get_image_window(win=1, size=None, wintitle=None)

return an image display

  • win (int) – index of Image Window (1 to 100)

  • size (tuple) – width, height in pixels of Image Window

  • wintitle (str) – text for Window title [Image Window N]


diplay, a wxmplot ImageFrame.


this will either return the existing ImageFrame for the window index or create a new one.

As with wx.PlotFrame, the returned wx.ImageFrame will have the same principle attributes to access the matplotlib Axes and Canvas objects.