Note that there are some explanatory texts on larger screens.

plurals
  1. POMatplotlib animate fill_between shape
    primarykey
    data
    text
    <p>I am trying to animate a fill_between shape inside matplotlib and I don't know how to update the data of the PolyCollection. Take this simple example: I have two lines and I am always filling between them. Of course, the lines change and are animated.</p> <p>Here is a dummy example:</p> <pre><code>import matplotlib.pyplot as plt # Init plot: f_dummy = plt.figure(num=None, figsize=(6, 6)); axes_dummy = f_dummy.add_subplot(111); # Plotting: line1, = axes_dummy.plot(X, line1_data, color = 'k', linestyle = '--', linewidth=2.0, animated=True); line2, = axes_dummy.plot(X, line2_data, color = 'Grey', linestyle = '--', linewidth=2.0, animated=True); fill_lines = axes_dummy.fill_between(X, line1_data, line2_data, color = '0.2', alpha = 0.5, animated=True); f_dummy.show(); f_dummy.canvas.draw(); dummy_background = f_dummy.canvas.copy_from_bbox(axes_dummy.bbox); # [...] # Update plot data: def update_data(): line1_data = # Do something with data line2_data = # Do something with data f_dummy.canvas.restore_region( dummy_background ); line1.set_ydata(line1_data); line2.set_ydata(line2_data); # Update fill data too axes_dummy.draw_artist(line1); axes_dummy.draw_artist(line2); # Draw fill too f_dummy.canvas.blit( axes_dummy.bbox ); </code></pre> <p>The question is how to update the fill_between Poly data based on line1_data and line2_data each time update_data() is called and draw them before blit ("# Update fill data too" &amp; "# Draw fill too"). I tried fill_lines.set_verts() without success and could not find an example...</p> <p>Thanks!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload