Both contour and 3d plots can be done easily in pgfplots, but I have a hard time combining them nicely.
Here's an example of what I'd like to achieve (from the matplotlib examples):
Pgfplots can compute the z contours by means of gnuplot and its
The projection onto the x axis (i.e. with fixed y) can be done by means of a matrix line plot in which you replace the y coordinate of the input matrix by some fixed constant.
The projection onto the y axis (i.e. with fixed x) is more involved (at least if
Here is what I got so far:
As you see, the first contour is the z contour. It is computed using gnuplot (and requires the
The x and y projections are computed using the same matrix of function values. I chose a different sampling density to control how many "contour lines" shall be drawn. Note that these lines are conceptionally different from the z contours: they are already part of the sampling procedure and do not need to be computed externally. Note that I used
here is a solution with
and the same for a more complicated funktion:
The code is redundant, specially because the function in
The result is the following:
The code follows: