Interpolated data contour plot like surface

Dear Plots experts—sorry, another question. if I have 3-D data (not function), I can use surface for a nice interpolated plot. alas, it’s not been adapted to a contour plot. and it clearly needs some smoothing aspects, like loess, over x-y-z (not just over x-y). still, it would be very nice. does anyone know if such a thing exists?

using Plots
n=100; xr= 10*rand(n); yr= 10*rand(n); zr= Float64[ sin(xr[i])+cos(yr[i]) for i=1:n];
surface( xr, yr, zr )  ## does polygonal interpolation
contour( xr, yr, zr )  ## no such method

that depends on the backend, I think - gr should interpolate contours. By the way, a better way to get support is to go to the Plots gitter channel, or the plots-bridged Slack channel - discourse is more intended for persistent discussion.

thx, m. nope, gr is the default backend, and it cannot contour data, only functions.

PS: gitter is not topics-header organized. how can one keep track of conversations there?? it’s like a cacophony.

It sounds like you need some kind of interpolation - maybe Interpolations.jl?

thx, dps.

looks too involved. the idea was to plot x,y,z data sets. Interpolations.jl seems to work happiest with regular grids. (only linear is supported without it.) With x and y not spaced equally, it’s not obvious enough to me how to work this well. plus, I think (but am not certain) that I have run into some bugs on Interpolations, either in the docs or in the package.

You can do it with GMT.jl. Unfortunately I forgot to port the contour module to the v0.5 version, but it’s now in master. With it you can do (contour the Matlab peaks function, also in GMT.jl)

x,y,z=GMT.peaks();
contour([x[:] y[:] z[:]], cont=1, annot=2, frame="a", fmt="png", show=1)

Without the master version you will have to use the Monolithic method

gmt("pscontour -C1 -A2 -Ba -JX10c -W1p -R-3/3/-3/3 -P > cont.ps", [x[:] y[:] z[:]])
gmt("psconvert cont.ps -A -Tj -Fcont");    # Convert from PostScript to jpeg