On 05/13/2011 05:19 AM, Johannes Radinger wrote:
>
> -------- Original-Nachricht --------
>> Datum: Fri, 13 May 2011 10:58:15 -0400
>> Von: Michael Droettboom<md...@stsci.edu>
>> An: matplotlib-users@lists.sourceforge.net
>> Betreff: Re: [Matplotlib-users] eps output and fill_between
>
>> Running it through gs (ghostscript) gives this error:
>>
>> =====
>>
>> GPL Ghostscript 8.70 (2009-07-31)
>> Copyright (C) 2009 Artifex Software, Inc.  All rights reserved.
>> This software comes with NO WARRANTY: see the file PUBLIC for details.
>> Error: /stackoverflow in -file-
>> Operand stack:
>>      --nostringval--
>> Execution stack:
>>      %interp_exit   .runexec2   --nostringval--   --nostringval--
>> --nostringval--   2   %stopped_push   --nostringval--
>> --nostringval--   --nostringval--   false   1   %stopped_push   1846
>> 1   3   %oparray_pop   1845   1   3   %oparray_pop   --nostringval--
>> 1829   1   3   %oparray_pop   1723   1   3   %oparray_pop
>> --nostringval--   %errorexec_pop   .runexec2   --nostringval--
>> --nostringval--   --nostringval--   2   %stopped_push
>> Dictionary stack:
>>      --dict:1148/1684(ro)(G)--   --dict:0/20(G)--   --dict:75/200(L)--
>> --dict:7/8(L)--
>> Current allocation mode is local
>> Current file position is 675310
>> GPL Ghostscript 8.70: Unrecoverable error, exit code 1
>>
>> =====
>>
>> This indicates that the Postscript is running out of stack space
>> (memory).  Indeed, the file has a very large path in it.
>>
>> A little background: matplotlib includes an algorithm to "simplify"
>> really long paths by removing points that don't actually contribute to
>> the resulting image.  Unfortunately, this algorithm only works for
>> unfilled paths -- dealing with the more general case of filled paths is
>> more difficult.  That's why you only see this problem when using
>> "fill_between" and not just when plotting lines.
>>
>> The problem here is that it's hard to trap for this error -- the size of
>> the Postscript stack is dependent on the Postscript interpreter being
>> used, so what works in one place may not in another.
>>
>> A simple way around this is to just decimate the data, i.e.:
>>
>>     plt.plot(x[::5], pdf_min[::5], x[::5], pdf_max[::5], color="k")
>>     plt.fill_between(x[::5], pdf_min[::5], pdf_max[::5], color='0.85')
>>
>> but obviously that's not doing anything terribly smart, so it won't work
>> with all data.
>
> First thank you for that way how it works...
>
> just some short questions, after I tried it this way (and it is working:)):
> 1) What does this decimate [::5] actually mean, what does it?

It takes every 5th point and ignores the rest.  It is an example of 
python slicing, which means taking a uniformly-spaced subset of a sequence.

> 2) In which case will it fail if you say it won't work with all data?

Two failure modes: (1) if taking every 5th point still leaves too many 
points; (2) if taking every 5th point leaves out points that would have 
an important effect on the shape of the curve, so the figure you end up 
with is not an accurate representation of what you are trying to plot.

> 3) Actually I have to use that [::5] only for the fill_between as the usual  
> line plot works, or am I wrong?

Correct.  What Mike is saying is that for ordinary lines, mpl has a 
sophisticated algorithm for eliminating points that don't affect what 
one sees in the figure, so it is much less likely that the postscript 
renderer will run out of stack space; but this algorithm is not used for 
filled regions because points that are not needed for representing a 
line might still be needed for a filled region.

Eric

>
> /johannes

------------------------------------------------------------------------------
Achieve unprecedented app performance and reliability
What every C/C++ and Fortran developer should know.
Learn how Intel has extended the reach of its next-generation tools
to help boost performance applications - inlcuding clusters.
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to