The answer of pgfplots for "mesh plots with smooth boundary" is its
patchplots library, combined with one of the higher-order patch types. Take, for example,
patch type=biquadratic : its boundaries are second order polynomials. This allows to provide a coarse-grained grid combined with smoothness.
The cost for such a format is to provide patches in a nontrival sequence: coordinates
0 1 2 3 4 5 6 7 8
are interpreted as the following points on a (single) rectangle:
3 6 2
7 8 5
0 4 1
the next 9 points make up the next rectangle and so forth. Here, points 0,1,2,3 make up the corners whereas points 4,5,6,7 are used to define the boundary parables. Point 8 is only relevant if you have
shader=interp; I think it is unused for
If you combine the approach with
shader=faceted interp, you get smooth fill colors + mesh lines.
Examples and images can be found in Section 5.6 Patchplots Library.
Of course, the cost is to manually arrange your input coordinate sequence in the format shown above - one set of 9 arranged points for every patch. To simplify this, you can also provide a single list of coordinates, and a connectivity table which tells
pgfplots that patch 0 consists of vertices with indices #42 #5# #7 #3 #30 #12 ... (see the
patch table option of
The alternatives are (as percusse already mentioned) to combine two plots: one which only fills the surface and one which provides the mesh. However, this has a severe limitation:
pgfplots only considers image depths inside of one single plot (compare the discussion and the alternative solution described in Section "5.6.4 Drawing Grids" in the patch plots library.
pgfplots has no option to "draw only each Nth mesh line".
I have just realized that your example function is a biquadratic function! As such, you only need one patch to capture its boundary without any loss in precision - and the effort to put input coordinates into the requested sequence is limited to only 9 points. That can be done by means of
\addplot table[z expr=<expression>].
Only the color interpolation is of first order (because pdf only supports bilinear interpolation). Consequently, you can get the effect for your example function using
shader=faceted interp combined with
patch refines - and just one patch as input:
\addplot3[patch,patch refines=3,shader=faceted interp,patch type=biquadratic]
Here is it with