I'd like to know if a matplotlib chart be interactive, ie when you right click on a graph bar, a context menu opens, then you click one of the menu items and change the value of y value or you drag the top edge of the bar with mouse and it becomes taller etc,
In other words, can a matplotlib chart act like a GUI?
yep, though I should warn you: matplotlib isn't the best choice for interactive tasks. Depends on your tasks you may face performance or UX issues..
Take a look at the Chaco. It was designed for the creation of complex interactive plots.
Yes.
Matplotlib is based on Tkinter, so you can do all sorts GUI related things with it. For an example of how you can embed matplotlib in a Tkinter GUI see here:
http://matplotlib.org/examples/user_interfaces/embedding_in_tk.html
Similarly for the functionality you are describing, you require plots that know when they've been clicked on (or mouse-overed) and that you can add callback events to. For that, the first place to look would be picker events:
http://matplotlib.org/examples/event_handling/pick_event_demo.html
As an alternative to some of the other ideas I would propose the Ipython notebook. For me it is the easiest way to do some of the things your asking about without having to get into Tkinter etc.
From Ipython 2.* onward there are interactive widgets allowing you to interact with the kernel from a GUI. I am not an expert in any sense so it is probably best explain by Fernando Perez himself.
Here is an example of interaction when solving the Lorenz differential equation demonstrating a chaotic system. This is accessible in the example of the ipython directory.
Related
I want to visualize one or more STL file(s) using a vtk render viewport inside my application. I was able to get it all running with this example here: https://kitware.github.io/vtk-examples/site/Python/IO/ReadSTL/
My question is as follows: I have a mouse to control it and it is just unbelievable how bad default the controls of the camera are. It is almost impossible to get the model rotated intentionally or focus on a certain part. I am confused as I could not find any topic here or elsewhere discussing this. Normally I would read through other threads to find an answer, but there doesn't seem to be any. So, maybe you can point me to an approach or even certain functions of how I can change these settings, that would be really great! Basically I want to mimic the camera behavior of say, Paraview or a common CAD tool. Like zooming with mouse wheel, rotating with RMB and holding down the wheel to pan.
Some background on my project: I have written a python program and created a quite ok UI using tkinter. However, recently I was thinking of rewriting some basic parts of it and also upgrading everything visually and in terms of handling. So, I want to move to Qt widgets and, there shall be a VTK rendering viewport inside my application to show some of the stuff that can be interacted with.
I was able to find a solution in the tutorials. By explicitly defining the vtkInteractorStyle with
style = vtk.vtkInteractorStyleTrackballCamera()
The handling is just as I wanted it to be.
I'm looking for a toolbar for matplotlib figure that contains more options than the basic one, which is automatically set in pyqt environment.
I already know how to add my own button, but I'm looking for a more advanced Toolbar already coded, that I can used directly.
In Matlab, for instance, it is possible to add points in the panel, or a text directly on the figure from the figure itself.
Outside of the one you're using, I don't think so. Try bokeh. Depending on your environment, ipywidgets may work too.
Hope that helps!
Is there any way of getting interactive tooltips in a matplotlib plot? For instance, I wanted to get this scatter plot with hovering tooltips (http://mpld3.github.io/examples/scatter_tooltip.html) functionality in my python application, because they are really useful for visualizations. Unfortunately, I do not want to show this in a browser, but integrated in my own python application, is there any way to do this?
Matplotlib can only create static images and animations. If you want something interactive, then the only way you're going to achieve this is by using a module that outputs javascript. I would suggest reading about bokeh.
It is well developed and gaining a lot of traction in the python world as being a good option for creating interactive plots. Here's an example of bokeh's hovertool capability.
Unfortunately, I do not want to show this in a browser, but integrated in my own python application
I'm not sure what your "own python application" is but you're not going to have a fun time making an interactive plot outside of a browser. I would highly suggest going a webapp route using bokeh if interactivity is truly important to you.
I am trying to build a GUI with wxPython to control a pretty stable, well-established model. The standard output of the model includes a series of plots to screen done via matplotlib. These plots are all OK if the model is run from the command line. If I run from my new GUI, however, they all show up, but I have no control over them: I can't click their respective "save" buttons; if they get covered up by other windows, they are "grayed out" when the blocking window is moved away. Things like that. If I close my GUI window, however, I get full control of my plots again. But this is no way to run this code.
I think my procedure is pretty standard. The bare outlines of the code are:
import wx
import model_code
class gui_for_model(wx.Frame):
# lots of stuff with hooks into model_code,
# including a "go" button that starts model_code running
#end of class
app=wx.App(False)
gm = gui_for_model()
app.MainLoop()
Anyone know what I should do differently? Thanks.
Here is a link to a site that has some demo code of using matplotlib with wxPython GUIs.
eli.thegreenplace.net/2008/08/01/matplotlib-with-wxpython-guis
Also this - matplotlib.org/faq/usage_faq.html talks about changing the backend.
And i found a package on pypi pypi.python.org/pypi/wxmplot/0.9.12
I want to visualize some measurement values in realtime. I think - although not finally sure - I can do this with PyChart. The surrounding application is based on PyQt.
Now I', wondering how I can put the chart drawn using PyChart into some qt widget, may be a QGraphicWidget?
Could someone give me a bit advise?
Cheers,
Wolfgang
I have learned to do this by following the instructions of Eli Benderski.
It is answered here on this site in this thread
Demo Code is here
This uses matplotlib instead of PyChart. Usage of matplotlib is well documented here.
Matplotlib allows you to interact with the plot canvas as well as importing a Navigation Tool Bar.
Hope this is helpful.