I am solving the Cahn hilliard equation, and it's already working. If i plot the figures at different iterations I obtain the correct result at the end. However, I need to show the change in concentration over the course of time in a video and not in multiple plots. I have tried using FuncAnimation but I can't figure out how to do it. I can't create a function that includes the frames. My concentration matrix is already updating after each iteration so how can I just tell the code to plot every update on the video?
Related
I am using Python for processing large datasets.
Each part of the data in the dataset is processed step by step in a cycle.
I need to add some visualization during processing.
Now I do plotting using matplotlib for current portion of data. For each step of the cycle I am executing function plot which plots new figure for each step..
The problem is I have a lot of data and plots... E.g. 1000000 plots, and if I will output it in Jupyter it just crashes. I want to use one figure and update data on it through a cycle and show it to see processing?
I want to create a ONE plot but the data on that figure will be changed on each step of processing - for current portion of data.
How to do that - to see that image during processing (e.g. using jupyter notebook)?
(So running through a cycle in one cell will show only one figure with one plot but the scatter on that plot will change cycle by cycle updating the existing figure)
something like:
update_plot(plot_name: str, datax: np.array, datay: np.array)
that will CHANGE the existing plot (important - I need to see it on the screen on each step - to understand that there is progress and it works correctly) It's like animation where each step - is a frame that needs to be changed. E.g. I am adding a special point on a plot for each step.
I'm trying to animate a Matplotlib quiver. On every step amount of points, which are shown, is changing. This fact ruins the 'xy' scale, and I get errors 'Operands with different shapes cannot be broadcast together', where one shape belongs to x array in the first frame, and the other to current. When I change scale to 'inches' everything works fine.
So my question is: can I modify quiver scale in animation, so that it could properly handle new amount of points?
Thanks for any help.
I'm trying to create a matplotlib graph that shows how to a certain data set changes over time. What I've been trying to do is create a plot and show it, pause for one second, clear the plot, and then show the next one in the array. I've gotten pretty close with the code below, but sadly it just crashes as is.
for expo in sorted_data:
plt.plot(expo["x"], expo["y"])
plt.show(block=False)
time.sleep(1)
plt.gcf().clear()
sorted_data contains the data sorted by when the data was collected.
Use matplotlib.animation. You can find many examples here: http://matplotlib.org/examples/animation/index.html
I'm working with data consisting in 2M points of aceleration in time, what im doing is apllying FFT to de dataset and ploting it to see behaviours.
I did it with Matplotlib but i have the problem that i can not see or select any point to see to wich (x,y) value correspond, too that i trully need (in matlab plot you can do it with a plot tool). I tried Bokeh but the problem is that is too slow plotting and ive been having some issues showing the plots (sometimes it plot, sometimes dont).
So my question is is there is any way to select (x,y) value (by clicking) in Matplotlib or if there is any plot tool to do this in a fast way?
this is the ploting data
I am using Python 2.7.9 with matplotlib to display live data taken from a microcontroller in a FigureCanvasTKAgg. The figure itself must always display the last 100 points and resize the Y axis to display and 'snug fit' all points. X axis is updated as well to show the correct time stamp of each point.
This figure update involves redrawing all artists (as all of them change) at every figure update which is called using an after method every 100ms. I am using line.set_data(x,y) to update the actual data points and the required methods for updating the Y and X axes limits, followed by canvas.draw(). This works OK, at almost 5fps(the drawing itself takes ~100ms).
My question is: is there a faster way of doing this? From what I understand the draw method redraws the whole canvas including the subplots. Is there a way to update only the lines displayed and the splines and hence increase the fps?
I tried implementing a solution using ax.draw_artist(lines) and the rest, however this adds new artists and do not delete the previous ones.