Menu

#749 Fix filledcurve seams appearing in PDFs

Version 5
closed-accepted
nobody
None
5
2017-09-04
2017-03-08
No

Filling between data curves with filledcurve produces a set of quadrilaterals. In many PDF viewers, antialiased rendering can lead to seams appearing. This problem has been reported in various places, such as here, which includes a nice zoomed-in screenshot of the issue.

This problem can be avoided by rendering entire polygons rather than splitting the filled curve into quadrilaterals. I've implemented this in the attached patch (against gnuplot 5.0.5), and verified (using Evince) that the seams disappear.

1 Attachments

Discussion

  • Ethan Merritt

    Ethan Merritt - 2017-03-08

    After applying your patch to current cvs source for version 5.0

    gnuplot> load 'fillbetween.dem'
    Hit return to continue
    Hit return to continue
    Hit return to continue
    gnuplot> 
    

    Inspection of output shows intended difference from unpatched output.
    So far, so good.

    However....

    gnuplot> load 'fillcrvs.dem'
    *** Error in `./gnuplot': malloc(): memory corruption: 0x0000000001e0c240 ***
    ^C^Z
    kill %1
    
    valgrind --tool=memcheck --leak-check=yes --log-file=valgrind.log gnuplot fillcrvs.dem
    

    The memory corruption is too severe to catch in gdb, but perhaps the valgrind output is informative.

    FYI but separate from whatever bug is present, the reason gnuplot draws filledcurves the way it does to avoid limitations in standard PostScript output. gnuplot orginally did something more similar to your approach but
    1) Some postscript interpreters are limited to a certain maximum number of vertices defining a closed curve. Reasonable plots could exceed this maximum, making the output ps file unusable.
    2) Accumulated round-off error in the coordinates can make the start/end points not meet up. This may be the reason that the interpreters impose a limit on the maximum number of vertices, but even if you don't exceed that maximum it can produce odd results.

    Neither of these old problems applies to non-postscript output so far as I know, and maybe modern postscript implementations don't hit this anyhow, but I worry a bit. If you get your code fixed up we might still want to make it optional or only used by certain terminal types.

     
  • Jeremy Green

    Jeremy Green - 2017-03-08

    Sorry, that was a silly error. I've simplified the memory allocation slightly in this new version.

     
  • Ethan Merritt

    Ethan Merritt - 2017-03-21
    • status: open --> pending-accepted
     
  • Ethan Merritt

    Ethan Merritt - 2017-03-21

    Applied to the development version (5.1).
    Can be added for 5.0.7 if no problems are reported in the development version.

     
  • Ethan Merritt

    Ethan Merritt - 2017-09-04
    • Status: pending-accepted --> closed-accepted
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.