Note that there are some explanatory texts on larger screens.

plurals
  1. POModifying filled area in matplotlib
    primarykey
    data
    text
    <p>I've an interactive figure on which plot is drawn incrementally, one chunk at time.</p> <p>That is, in a loop I get some sampling data, then I add them to existing curves in the plot and redraw the picture. For this, I'm using get/set_x/ydata functions. Something on this line:</p> <pre><code># Get initial data time = [1, 2, 3, 4, 5] samples = [0.1, 0.2, 0.3, 0.4, 0.5] c = plot_curve(time, samples) # Get new data time2 = [6, 7, 8] samp2 = [0.6, 0.7, 0.8] c.set_xdata(append(c.get_xdata(), time2)) c.set_ydata(append(c.get_ydata(), samp2)) </code></pre> <p>Problem is, I'm also filling some area near the curve (e.g. the space between the curve and the x axis), using fill_between. Currently, I'm creating lots of small chunks in this way:</p> <pre><code># Filling initial chunk fill_between(time, samples, [0 for i in time]) # Filling next chunk fill_between(time[-1] + time2, samples[-1] + samp2, [0 for i in time2] + [0]) </code></pre> <p>(I know this code stinks, but it's for giving an idea).</p> <p>So, problem is: there is one curve, but filled areas are 2 (one for each data chunk). This creates small artifacts in the drawing, because each filled area is very near to the next one, with a very little space among them.</p> <p>Is there a way to do this kind of incremental work also on the filling area?</p> <p>For example, could be nice to keep 2 curves (one equal to c.get_ydata() and one of zeros) and having matplotlib to automatically fill the area between them, without having to call the command explicitly - so that the filled area would always be up-to-date with the sampling points.</p> <p>Or, another nice way, would be to represent the filled area using the sampling points, instead of a polygon, so that I could update the area with method similar to get/set_x/ydata.</p>
    singulars
    1. This table or related slice is empty.
    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