#332 Filled Contours


I think this was a feature discussed in around 2006, judging from Google searches, and it's something that deserves to be brought up again. Filled contours are a pretty standard feature in other plotting software. See for example matplotlib: http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.contourf

Here's the application that needs it: examining decision surfaces of a classifier: http://scikit-learn.org/dev/modules/ensemble.html#forests-of-randomized-trees (clicking on the image shows the source code and the use of overlapping filled contours)

Some discussion on Google shows that there was once a "set pm3d at C" feature that was abandoned because contours don't currently close on themselves, as required for filledcurves to work. Also, using pm3d with a discretized palette has many disadvantages, most notably that the pixels don't align with the contour lines, if you choose to show them, and the inherent computational costs of increasing the isosample resolution (not to mention unnecessarily large file sizes!)

In any case, it seems like a ripe time to bring this one up again and see if there are any new insights!


  • Ethan Merritt
    Ethan Merritt

    The plots in the example you point to look to me like they can be generated without doing any contouring at all. I might be missing something, but they have the appearance being generated by having each point contribute to the coloring of the entire vertical and horizontal segment in which it lies. The different plots correspond to different rules about how that contribution is calculated.
    Anyhow, back to gnuplot's current capabilities...
    Some, but certainly not all, filled-contour plots can be created in two steps.
    1) Use "set table" to draw individual contour sets to file
    2) plot the resulting files, in order, using "with filledcurves"
    The filledcurves code has been improved so that there are fewer problems with unclosed areas than there used to be. But it's still a problem.