Giter Club home page Giter Club logo

wxmplot's Introduction

Version Downloads

wxmplot provides advanced wxPython_ widgets for plotting and image display of numerical data based on matplotlib. While matplotlib provides excellent general purpose plotting functionality and supports many GUI and non-GUI backends it does not have a very tight integration with any particular GUI toolkit. With a large number of plotting components and options, it is not easy for programmers to select plotting options for every stuation and not easy for end users to manipulate matplotlib_ plots. Similarly, while wxPython_ has some plotting functionality, it has nothing as good or complete as matplotlib_. The wxmplot package attempts to bridge that gap. With the plotting and image display Panels and Frames from wxmplot, programmers are able to provide plotting widgets that make it easy for end users to customize plots and interact with their data.

WXMplot provides wx.Panels for basic 2D line plots and image display that are richly featured and provide end-users with interactivity (zooming, reading positions, rotating images) and customization (line types, labels, marker type, colors, and color tables) of the graphics without having to know matplotlib. wxmplot does not expose all of matplotlib's capabilities, but does provide 2D plotting and image display Panels and Frames that are easy to add to wxPython applications to handle many common plotting and image display needs.

The wxmplot package is aimed at programmers who want to include high quality scientific graphics in their applications that can be manipulated by the end-user. If you're a python programmer who is comfortable writing complex pyplot scripts or plotting interactively from IPython, this package may seem too limiting for your needs. On the other hand, wxmplot provides more and and better customizations than matplotlib's basic navigation toolbars.

The main widigets provided by wxmplot are:

  PlotPanel: wx.Panel for basic 2-D line plots (roughly matplotlib `plot`)

  PlotFrame: wx.Frame containing a PlotPanel

  ImagePanel: wx.Panel for image display (roughly matplotlib `imshow`)

  ImageFrame: wx.Frame containing ImagePanel

2D Line plotting with PlotPanel /PlotFrame

PlotPanel and PlotFrame give the end-user the ability to:

  1. display x, y coordinates (left-click)
  2. zoom in on a particular region of the plot (left-drag)
  3. customize titles, labels, legend, color, linestyle, marker, and whether a grid is shown. A separate configuration frame is used to set these attributes.
  4. save high-qualiy plot images (as PNGs), copy to system clipboard, or print.

For the programmer, these provide simple plotting methods:

plot(x,y): start a new plot, and plot data x,y

Some of the optional arguments (all keyword/values) include

  color='Blue'       for any X11 color name, (rgb) tuple, or '#RRGGBB'
  style='solid'      'solid,'dashed','dotted','dot-dash'
  linewidth=2      integer 0 (no line) to 10
  marker='None'  any of a wide range of marker symbols
  markersize=8    integer 0 to 30
  xlabel=' '           label for X axis
  ylabel=' '           label for Y axis
  title=' '              title for top of PlotFrame
  grid=True         boolean for whether to show grid.

oplot(x,y): plot data x,y, on same plot as current data

 with optional arguments as plot()

clear(): clear plot

save_figure(): bring up file dialog for saving image of figure

Image Display with ImagePanel and ImageFrame

This displays a numpy array as an greyscale or false color image. The end user can zoom in, rotate, or flip the image, and adjust the smoothing of the image and adjust the color table and intensity scale.

Programmatically, one can make the same adjustments to an ImagePanel by changing its configuaration attributes and running the redraw() method.

=====

last update: 2018-Oct-13 Matthew Newville [email protected]

wxmplot's People

Contributors

astyl avatar beldramma avatar christiansandberg avatar jkbgbr avatar newville avatar rbaumert avatar tobiasgehring avatar vstadnytskyi avatar yanikou19 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wxmplot's Issues

problem with stripchart.py in examples directory

The output is slightly different from running the original code with these changes, but the result is the same. this tracback is:

Traceback (most recent call last):
File "/Users/allengordon/Documents/workspace/pgsolar/wxmplot/examples/stripchart.py", line 110, in onTimer
t2, y2 = next_data
TypeError: cannot unpack non-iterable function object
Traceback (most recent call last):
File "/Users/allengordon/Documents/workspace/pgsolar/wxmplot/examples/stripchart.py", line 110, in onTimer
t2, y2 = next_data
TypeError: cannot unpack non-iterable function object

running the somewhat modified code as is to plot one trace in real time works just fine. However, I added some code to plot two traces and get "TypeError: 'NoneType is not subscriptable'. The code I changed is:

def onTimer(self, event):   #5

    self.count += 1
    etime = time.time() - self.time0
    self.tmin = float(self.time_range.GetValue())
    t1, y1 = next_data()
    _**t2,y2 =next_data()**_    #new
    self.tlist.append(t1)
    _**self.tlist.append(t2)**_   #new
    self.ylist.append(y1)
    _**self.ylist.append(y2**)_    #new
    tdat = np.array(self.tlist) - t1
    mask = np.where(tdat > -abs(self.tmin))
    ydat = np.array(self.ylist)

The output is this:

<next_data>
1657906492.479019
0.31490781630084264
<next_data>
1657906493.479179
0.33375499766168376
Traceback (most recent call last):
File "/Users/allengordon/Documents/workspace/pgsolar/schartdev/stripchart.py", line 145, in onTimer
self.plotpanel.update_line(2, tdat, ydat, draw=True)
File "/Users/allengordon/Documents/workspace/pgsolar/schartdev/wxmplot/plotpanel.py", line 713, in update_line
x = self.conf.get_mpl_line(trace)
File "/Users/allengordon/Documents/workspace/pgsolar/schartdev/wxmplot/config.py", line 738, in get_mpl_line
return this[0]
TypeError: 'NoneType' object is not subscriptable

Configure Plot

I am new in using wxmplot and find it comfortable. There is one thing I cannot get run: it is the plot configuration. When I choose "right mouse->config" on the plot or "main menu->options->configure plot" nothing happens. It even doesn't work for the simpliest example "WXMPlot Demo". The zoom methods in the context menu work fine.
I guess it has something to do with my OS/installation. I am using Canopy Enthought on Windows 7 and installed wxmplot via pip install.
Grateful for any help.

cmy_image.py fails to run

Trying to run cmy_image.py fails with

Traceback (most recent call last):
  File "cmy_image.py", line 35, in <module>
    subtitles={'cyan':'Cyan Image', 'magenta': 'Magenta Blob', 'yellow': 'other'})
  File "/home/antony/src/extern/wxmplot/build/lib/wxmplot/imageframe.py", line 443, in display
    self.set_subtitles(**subtitles)
TypeError: set_subtitles() got an unexpected keyword argument 'cyan'

Missing Function

I have a program that crashes when I use the Zoom feature. Zooming in or out does not work. I traced the problem back to the function set_viewlimits in basepanel. The problem is that the function, to my knowledge, doesn't exist.

Is this a callback I am supposed to set in order for zoom to work?

UPDATE_LINE option

I was going through the demo.py example, there is an update_limits option in the update_line function (line 283) that does not seem to be found anywhere in the documentation. I also don't see any difference with it set to either value. Am I missing something? Please, let me know.

Frame for multiplot not properly destroyed.

I runned the example given for multiplot on Spyder. The first time I executed my program, it is okay, but the second time I have this mistake :
` wx.Frame.init(self, parent, -1, title, **kws)

PyNoAppError: The wx.App object must be created first!`

problem installing wxplot on MacOS 12.2.1

got this error building wxpython after cloning the project and running pip install. I had to install wheel package separately to prevent use of legacy. I also ran pip install wxpython which failed as well

/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/dist.py:717: UserWarning: Usage of dash-separated 'license-file' will not be supported in future versions. Please use the underscore name 'license_file' instead
warnings.warn(
running build_ext
building 'wx.svg._nanosvg' extension
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch arm64 -arch x86_64 -g -DNANOSVG_IMPLEMENTATION=1 -DNANOSVGRAST_IMPLEMENTATION=1 -DNANOSVG_ALL_COLOR_KEYWORDS=1 -Iext/nanosvg/src -I/Library/Frameworks/Python.framework/Versions/3.10/include/python3.10 -c wx/svg/_nanosvg.c -o build/wxsvg/temp.macosx-10.9-universal2-3.10/wx/svg/_nanosvg.o
wx/svg/_nanosvg.c:5761:72: warning: array subscript is of type 'char' [-Wchar-subscripts]
__pyx_t_2 = PyFloat_FromDouble((__pyx_v_self->_ptr->strokeDashArray[__pyx_v_i])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 364, __pyx_L1_error)
^~~~~~~~~~
wx/svg/_nanosvg.c:20946:19: error: implicit declaration of function '_PyGen_Send' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
ret = _PyGen_Send((PyGenObject*)yf, value == Py_None ? NULL : value);
^
wx/svg/_nanosvg.c:20946:17: warning: incompatible integer to pointer conversion assigning to 'PyObject ' (aka 'struct _object ') from 'int' [-Wint-conversion]
ret = _PyGen_Send((PyGenObject
)yf, value == Py_None ? NULL : value);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
wx/svg/_nanosvg.c:20951:19: error: implicit declaration of function '_PyGen_Send' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
ret = _PyGen_Send((PyGenObject
)yf, value == Py_None ? NULL : value);
^
wx/svg/_nanosvg.c:20951:17: warning: incompatible integer to pointer conversion assigning to 'PyObject ' (aka 'struct _object ') from 'int' [-Wint-conversion]
ret = _PyGen_Send((PyGenObject
)yf, value == Py_None ? NULL : value);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
wx/svg/_nanosvg.c:21035:19: error: implicit declaration of function '_PyGen_Send' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
ret = _PyGen_Send((PyGenObject
)yf, NULL);
^
wx/svg/_nanosvg.c:21035:17: warning: incompatible integer to pointer conversion assigning to 'PyObject *' (aka 'struct _object ') from 'int' [-Wint-conversion]
ret = _PyGen_Send((PyGenObject
)yf, NULL);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 warnings and 3 errors generated.
error: command '/usr/bin/clang' failed with exit code 1
Command '/Library/Frameworks/Python.framework/Versions/3.10/bin/python3.10 setup-wxsvg.py build_ext --inplace' failed with exit code 1.
Finished command: build_others (0.906s)
Finished command: build_py (0m17.292s)
Finished command: build (0m26.553s)
Command '"/Library/Frameworks/Python.framework/Versions/3.10/bin/python3.10" -u build.py build' failed with exit code 1.
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> wxPython

note: This is an issue with the package mentioned above, not pip.

latex errors not handled gracefully

As matplotlib handles only a subset of latex, it's easy to break labeling, and errors are not handled gracefully.
In the code, relabeling is both too spread out, and then consolidated into config.relabel(), making it hard to detect what label is causing the error.

Should probably switch to strict use of config.set_xlabel(), config_set_title(), etc. A popup warning message should occur for
non-compliant latex labels.

add scatterplot as from mpl CircleCollection

A scatter plot that supports lassoing as an alternative to zooming should be added to PlotPanel (or made a separate ScatterPlotPanel?). The configuration for this should include the plotpanel configuration, minus line/trace settings, and plus circle size, normal color and highlighted color.

Plot does not update when zooming in

I have written wxmplot panel which is linked to the selection made by user. The plotting feature works perfectly fine. However when I try to zoom in into the graph, it zooms into the graph created by previous event. In other words the everytime I make new selection the graph is not being updated

two show legend checkbox

in the "configure plot" frame, both "colors and line properties" and "text, labels, legends" have the checkbox "show legend", their function are same, but when i click one of them, the other won't change state accordingly. I think it should behave this way.

Problem using plotlib in windows 11 Enterprise

Receiving the following error in windows 11 Enterprise
Tried python versions: 3.8, 3.9, 3.10 with same result

File "C:\Python38\lib\site-packages\wxmplot\basepanel.py", line 519, in gui_repaint
and isinstance(self.canvas.figure._cachedRenderer, RendererWx)):
AttributeError: 'Figure' object has no attribute '_cachedRenderer'

Problem goes away when I comment out the following code block in basepanel.py

    if (wx.Platform == '__WXMSW__'
        and isinstance(self.canvas.figure._cachedRenderer, RendererWx)):
        bmp = bmp.ConvertToImage().ConvertToBitmap()

dash styles

plot/oplot() should allow a couple choices of 'dashed' styles, using line.set_dashes()

axes.panel.lines[i].set_dashes((on, off)) 

the default seems to be (6, 6),

I think having (4, 1) and (12, 5) would offer clear contrast

"Zoom out" breaks mouse clicks

Hi,
Reproducible with:

  1. left click in plot
  2. click zoom out
    2.1 everything still clickable
  3. left mouse down in view
  4. mouse click breaks

Traceback:
Traceback (most recent call last): File "/usr/lib/python2.7/site-packages/matplotlib/backends/backend_wx.py", line 1075, in _onLeftButtonDClick self.CaptureMouse() File "/usr/lib/python2.7/site-packages/wx-3.0-gtk2/wx/_core.py", line 10638, in CaptureMouse return _core_.Window_CaptureMouse(*args, **kwargs) wx._core.PyAssertionError: C++ assertion "!wxMouseCapture::IsInCaptureStack(this)" failed at ./src/common/wincmn.cpp(3271) in CaptureMouse(): Recapturing the mouse in the same window?
is this even a wxmplot bug?

PS: Didn't had the time for a PR on doc :(

Adding Pan mode and Zoom on X/Y only modes

Hi.
I am working adding these modes, that we can find with matplotlib. With the current program, it seems to me that I cannot add zoom only on X/Y functions in the zoom functions which already exist, so I will add two new cursors modes for these functions. Currently I am working on zoom on x mode, I am trying to create a rectangular box with its height equal to the height of the graph, but I don't know how to get back these values.
For pan mode, I tried to use the pan function from the Navigation toolbar from matplotlib.

Missing option 'use_dates' with PlotPanel.update_line() function

Sorry, I have zero experience in reporting issues.

But I believe I've found an error > if you succesfully draw a plot with wxmplot.PlotPanel.Plot() using the use_dates=True option and then you want to later update it with wxmplot.PlotPanel.update_line() and update_limits=True you'll get an error:

TypeError: '>' not supported between instances of 'float' and 'datetime.datetime'

The error I believe stems from config.py the set_viewlimits() function. More specifically I think it goes wrong here:

                        else:
                            limits = [min(limits[0], min(x)),
                                      max(limits[1], max(x)),
                                      min(limits[2], min(y)),
                                      max(limits[3], max(y))]

Which is the piece of code that will throw a TypeError if x contains datetime.datetime objects.

Hope this helps your team to further improve the code. If you need me to write a full piece of code that throws the error when you run it let me know. If the error is surely on my part due to wrong usage just mention so and I'll find my own solution.

Thnx!

Python36: missing UserDict in tests

With python36 python%type_raw[python] setup.py test fails with:

from UserDict import DictMixin
ModuleNotFoundError: No module named 'UserDict'

Presumably, all python3 versions are affected.

MultiPlotFrame example

Trying to run MultiPlotFrame example. Getting the following error message....
Python version: 3.5.3; wxPython version: 3.0.3.dev2891+36b8076 msw (phoenix)

AttributeError                            Traceback (most recent call last)
<ipython-input-1-9c35c2132dbc> in <module>()
     10 app = wx.App()
     11 
---> 12 pframe = wxmplot.MultiPlotFrame(rows=2,cols=3,panelsize=(2.5,1.75))
     13 
     14 

C:\apps\python35\lib\site-packages\wxmplot\multiframe.py in __init__(self, parent, rows, cols, framesize, panelsize, **kws)
     28         self.panelsize = panelsize
     29         self.current_panel = (0,0)
---> 30         self.BuildFrame()
     31 
     32     def set_panel(self,ix,iy):

C:\apps\python35\lib\site-packages\wxmplot\multiframe.py in BuildFrame(self)
    111         self.SetStatusText('',0)
    112 
--> 113         self.BuildMenu()
    114         sizer = wx.GridBagSizer(self.rows,self.cols)
    115 

C:\apps\python35\lib\site-packages\wxmplot\baseframe.py in BuildMenu(self)
    192         MenuItem(self, mopts, "Configure Plot\tCtrl+K",
    193                  "Configure Plot styles, colors, labels, etc",
--> 194                  self.panel.configure)
    195         MenuItem(self, mopts, "Toggle Legend\tCtrl+L",
    196                  "Toggle Legend Display",

AttributeError: 'NoneType' object has no attribute 'configure'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.