[R] persp fail with non-equidistant dates
Duncan Murdoch
murdoch.duncan at gmail.com
Mon Aug 22 17:53:18 CEST 2016
On 22/08/2016 11:17 AM, Tomas Bayer wrote:
> Hello,
> when I plotted non-equidistant data in 3D (using persp and contour), it
> was ended with the same error message:
>
>> persp(y, x, z, xlab="latitude", ylab="longitude", zlab="altiude",
> main="Altitude")
> Error in persp.default(y, x, z, xlab = "latitude", ylab = "longitude", :
> increasing 'x' and 'y' values expected
>
> How to fix it? The original data are in columns
>
> 50.84925 14.65715 614.0 48909.14 -62.49 99 48929 5 122306
> 50.84919 14.65702 617.0 48816.32 -145.82 69 48836 6 122331
> 50.84908 14.65681 622.0 49113.40 6.64 99 49133 4 122442
You haven't shown us what is in y, x and z, but it looks as though you
haven't got data in the form required by persp, i.e. a vector of
increasing values in each of the first two arguments, and a matrix of
values in the third. Using your variable names, you'd want z[i,j] to
correspond to y[i] and x[j].
If you just have a collection of (y, x, z) triples, you'll need to do
some pre-processing to fit a surface and produce the required inputs.
Duncan Murdoch
More information about the R-help
mailing list