Hello matplotlib users,
wxmplot 0.9.38 is now available and can be installed with pip install wxmplot
.
Docs are at https://newville.github.io/wxmplot/ and code at https://github.com/newville/wxmplot/.
I suspect many people here are not aware of this module that combines wxPython and matplotlib. I also think that some of you may find it very useful for making 2D line plots and image displays because the displays created are highly configurable and interactive.
With 0.9.38, interactive plotting from the Python command line (that is, from a plain Python terminal or a Jupyter qtconsole, notebook, or Juptyerlab) can be done with:
>>> import wxmplot.interactive as wi
>>> import numpy as np
>>> x = np.linspace(-5, 5, 101)
>>> wi.plot(x, np.sin(x), label='sine')
At first look, the results are similar to pyplot.plot()
: a new Plot Window with the 2D Line Plot. From this window, not only can the user zoom in, adjust the margins, and save an image as with the Navigation Toolbar, but they can also change the styling/theming, labels and titles, configure the legend, and so on. They can also change the color, marker, linewidth, label, and style of each trace. With the legend displayed, clicking on a legend label will toggle whether the corresponding trace is displayed. Additional functions such as wi.plot_text()
, wi.plot_marker()
, and wi.plot_axhline()
allow the user to add annotations to the 2D line plot.
For image displays, wi.imshow(image_data)
will display a false-color image of data, similar to pyplot.imshow(image_data)
, but with widgets, menu items, and keyboard shortcuts to allow the user to rotate, flip, or smooth the image, change color tables and contrast thresholds, display as a contour map, draw a scalebar, and show slices through the image.
The wxmplot.interactive
module does not use a blocking show()
function - the results are drawn immediately and are interactive, and the shell is not frozen while the plot is displayed. This means that from the Python shell, the user can additional traces to an existing plot, replace the current plot, or draw to a second (or more) separate Plotting or Image Display windows. When run with python myscript.py
, a script that uses the wxmplot.interactive
functions will show the displays, and these will persist (and be interactive) until closed. That is, the script will not finish and kill the displays until all displays are closed or until the script is explicitly killed with Ctrl-C.
There are some specialty displays available (see examples), but there are many aspects of matplotlib that have no equivalent in wxmplot. Still, I invite anyone interested to try out the basic plotting and image display as I think some of you may find it very useful for exploratory data analysis.
Wxmplot 0.9.38 uses and MIT license and supports Python 2.7, 3.5, 3.6, and 3.7, and requires matplotlib 2.0+, wxPython 4.0.2+, numpy, and six. Support for Python 2 will be dropped for the next release.
Feedback, suggestions, and improvements are most welcome.
Cheers,
–Matt Newville