Animations in Matplotlib: Making a "Loading Bar" - matplotlib

Note this example:
http://laplace.ucv.cl/Cursos/FisicaExperimental_2/Old/Python/Programas/strip_chart_demo.py
where an oscilloscope is animated out. Is there any way to use Matplotlib to control the pace that the graph is animated? I am trying to make a loading/progress bar and would like to control how quickly the loading bar expands. What I have tried is to change the line
gobject.idle_add(scope.update)
to
gobject.timeout_add(100, scope.update)
but that causes the line to not draw at all.
Any tips?

Related

Matplotlib: Figure controls (zoom, save, etc) disappear when figure too small

When a matplotlib figure is shrunk below a given size, the controls on the bottom disappear. I want to save the figure, at the size that I have stretched it too, but it seems that I cannot, because the save button disappears when the figure is that small. Is there any way around this, other than manually calling fig.savefig() in the code?
Edit: Backend is TkAgg
Ah, well it turns out there are keyboard shortcuts to the controls.
You can press CTRL-S to save (even on Mac - not Command-S).
The full list of shortcuts is here: https://matplotlib.org/users/navigation_toolbar.html
When using "Qt4Agg" or "Qt5Agg" as backend,
import matplotlib
matplotlib.use("Qt4Agg")
the navigation toolbar can be extended with the two small arrows as shown below.

Dygraphs - Legend disappears when Zoom is in progress

When I do a horizontal zoom on the Graph, Legend disappears and comes back when the zoomed graph is loaded.
Screenshots:
Do we have any option to make the Legend static/ appear even when a Zoom is in process internally instead of disappear/appear between zoom operations.
You might try setting hideOverlayOnMouseOut: false or legend: "always".

Tooltips disappear after zoom in/out when using matplotlib mpld3

I have a matplotlib figure with tooltips on the point markers:
And the zoom in/out is working:
However after the zoom in/out is performed the tooltips no longer function: and even restoring the original (non-zoomed) size they do not come back.
If you use the pan-and-zoom tool (crossed arrows icon), tooltips should remain unchanged after zooming. If you use the box zoom (magnifier icon), while box zoom is active, the tooltips are turned off. The tooltips should appear again after clicking the box zoom magnify icon a second time to deactivate it.
Perhaps this UI could be clearer.
Here is scatter plot with tooltips example you can use to see this in action.

How to make a Matplotlib window (i) transparent, (ii) not having a window title bar (at least with Ubuntu/Unity)

I want to plot a graph with Matplotlib and to keep updating it (reading values from a file as the file grows). I am using code based on this answer to dynamically read data from the file and it works.
Now I have two questions:
I would like to make the window displaying the figure transparent, so that the windows below it become visible. Setting alpha of figure.patch and axes.patch to 0 does not work, the window is still not transparent.
I would like to remove system title bar from the window. (I am using Ubuntu 13.04 with Unity).
In the end, I would like to have just a graph and, maybe, a bounding rectangle around it without anything else (or, with a semi-transparent black background).

How to create an "Add to reading list" animation effect

I'm trying to make an animation effect similar to the one on Safari(iPhone) when you add an element to the reading list. It's similar to the one that appears when starting to download an item from App Store application: the application item drops to the dock to start downloading.
First it bounces up and then goes to the dock. It's a very nice effect that Apple uses on their OS.
I have an image view on screen that I want to drop with this kind of animation to my toolbar in my application.
If there is someone who did it or know what's the name of the effect, could please tell me how to do it.
Thank you.
"Add to reading list" shows no animation on my phone but of your description it sounds like the "Open in background"-animation in Safari (iPhone). My answer describes that animation.
I wrote a thing like that a few months ago and much of it is doable while some of it is not. Your questions showed me that more people are to know how it is done so I wrote a blog post about it. I will describe the high level approach and challenges here but you can read more about it in that post.
Getting to content to animate
If you choose to animate the view that is on screen down to the (in your case) tool bar then you will only have to access its layer. If you want the original view to remain and animate a visual copy (like the "open in background"-Safari animation) down to the bar item then you should create a new layer and draw the content of your layer into an image and set that image as the content of the layer that you are animating
Calculating the end position
The start position of the animation is simply the frame of the view. The end position is very tricky since bar items (both tool bar items and tab bar items) are not UIView subclasses and doesn't have a public view property. This causes problems when you want to shake the bar item later on.
I decided to make a visual approximation of the end position using some simple heuristics. If you know before hand that you will only animate to a single bar item then the end position can be hard coded to a suitable frame.
Animating along a path
There is nothing special to moving, scaling and rotating the layer from the start to the end position. If you want to read more about how I did it you can look at the post I wrote.
Shaking the bar item
This cannot be done without a lot of custom code or using private API at the moment. Since bar items doesn't have a view or a layer there is no accessible layer for you to animate. I guess that you could have a custom animating image that does the shake and set that during the animation and set the new image afterwards. The approach of drawing into an image and animating that doesn't work that well either since there is no accessible layer who can draw its content into the image (you want this for the special effect of the tool bar item and tab bar item).
...put all this together and tweak it to your special needs and you will have an animation that resembles the animation you are looking for.