I am a graduate student with only limited knowledge of the Python programming language. I am currently working on creating a streaming visualization of EEG data. I am able to generate the individual topographical figures using matplotlib, but cannot find a way of dynamically updating a single plot in the output at specific intervals.
Is there some way of taking a list of Figure objects and dynamically displaying each one in turn after some interval in python 2.7? Perhaps using a Graphics object similar to the ones found in Java's Swing? Or would it be better simply to save my plots as images and use JavaScript to display them as desired?
Thank you in advance for any help or suggestions you may offer.
If you want to make an animation with Python, then there are plenty of ways. For example:
https://jakevdp.github.io/blog/2012/08/18/matplotlib-animation-tutorial/
http://matplotlib.org/examples/animation/double_pendulum_animated.html
http://matplotlib.org/examples/animation/dynamic_image2.html
Related
I am hoping to create some comparison plots using python- see the image included. They show categories with a start and end point using different colors, and divided by year, km section etc 9see image)
Could someone point me to a good starting place for this? I didn't see the right type of plot in matplotlib so I am wondering if there is another python module that could accomplish this.
This was done using a roundabout method in CAD but I'm sure there's a cleaner way in python. I'm still a beginner python user so I'm not savvy with what modules could accomplish this sort of chart
I'm using matplotlib and python to make an animated scatter plot with points as 'balls' that bounce around, just like this:
https://jakevdp.github.io/downloads/videos/particle_box.mp4
It is interactive at runtime (with sliders to change velocity, attraction, etc), simulating on the go.
I would like to then publish it with the interactivity and all in html.
Problem: I don't know of a way to publish matplotlib interactivity to html directly.
So can I do it in python? Or is there a better way?
Which library (or program, if different from python) would you recommend as the simplest and fastest for this kind of project? I don't need "pretty" customizations and all that, I just need easy calculations and simulations (python) to then plot in a few easy lines of code (matplotlib). I do need to change the dots (balls) colors though.
I have looked at mpld3 that should wrap matplotlib around D3js. But I don't know anything about js and it is not very straightforward, so it would take me a bit to learn.
I have also looked at plotly, but it doesn't seem to have the same customization of the animation I need.
I have looked at Dash with plotly, but it would be a whole new environment to learn, and definitely overkill.
So the questions are: is there a way to output matplotlib interactive animations to html that I haven't found?
If not, what tools would you use to accomplish this project within a fast timeframe and shallow learning curve, based on my beginner/low intermediate python and matplotlib skill level?
Thank you!
The scripts I use generate a lot of graphs. I was wondering if there was a way to save them or specified ones into a single file as image or pdf for quicklooks.
Thank you.
If you are using matplotlib, it would be easiest to use the subplots feature. This will make all of your graphs part of a single object, which can be saved as an image like you want. I would redirect you to the matplotlib website for a ton of good example on the subject. https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.pyplot.subplots.html
Then, do
fig.savefig('mysweetsubplots.png')
and you are done.
The graph below shows a ranking of countries at 10 different points. The cool thing with this graph is that it allows you to track changes in the ranking over time. I want to create create something similar, but I have no idea how it was created...
My guess is that it was created using some design tool like adobe indesign, but my hope is that there might be some other tools for obtaining such a graphic (maybe even a way to do it within Mathematica or Python?)?
Any ideas and/or suggestions on where to look would be much appreciated.
PS: In case I did not post this in the most appropriate of stackExchange's many forums--my apology.
it is called a bump chart, you can learn how to make it with python in this article
How to make a bump chart
Matlab and Mathematica both have features that allow the user to manipulate the contents of a plot using, say, a slider. For example, if you have a set of 3D data, it is easy to make a small program that lets you view 2D slices of a set of 3D data where the user can slide a slider to move through which slice is displayed. Is there anything in python that allows for this sort of capability without tons of effort? For example, is it possible to do such a thing in matplotlib, or something similar? I
Thanks.
My first thought would be Mayavi, which is great for data visualization, especially in 3D. It relies on VTK. It is included in the Enthought flavoured version of Python, together with Chaco for 2D plotting. To get an idea, look at Travis Vaught's nice screencast in Multidimensional Data Visualization in Python - Mixing Chaco and Mayavi.
It also possible to embed basic interactive functionalities (like slider) to Matplotlib, see matplotlib.widgets and the widget examples.
Finally, you can use rpy (or better, rpy2) and benefit from the R interface.
Have you looked at Vtk? http://www.vtk.org/ One of their demos does exactly what you're asking.
In principle, you can do it by help of MathGL. This is cross-platform GPL library for plotting.
For each mouse clicks you can find the x,y,z position in plot or clicked object and adjust (replot) some other information correspondingly. However you should handle mouse clicks by yourself (for example, using PyQt).
Another option is to use python within the SAGE computation interface/environment, which has the #interact command (see here for specific help on this command)