r - Plotting scalar field -


I was searching to plot this function as a scalar field in a specially consistent scaler field :

  Library (RGL) Issue = CEC (-2, 0, Length = 20) XY = Extension Grid (x = points, y = -points) zf & lt; - Function (X, Y) {X ^ 2-Y ^ 2; } Z & LT; - ZF (XY $ X, XYE Y) Open 3D () RGL Surface (x = points, y = matrix (z, 20), coord = c (1,3,2), z = points) Axes3d ()  

A scalar field is usually Two axis is plotted with X and Y, where Z represents the color ()

With ggplot () I can do this:

  Daf = data.frame (XY $ X, XY $ Y, Z) ggplot (daf) + geom_point (AES (XY.X, XY.Y, Color = Z))  

< Img src = "https://i.stack.imgur.com/ZheYc.png" alt = "Enter image details here">

but still not a continuous field.

This can be achieved by the 'image' function:

  Z & lt; - External (Points, Points, Zf) Image (Points, Points, Z)  

Scalar field

This method uses only the closest neighboring interpolation, but if you want a smooth representation, you can use other types of interpolation:

  Library (field) #Biller interpolation interp_points = seq (-2, 0, lengt H = 200) interp_bilinear & lt; - interp.surface (list (x = x, y = y, z = z), loc = expand.grid (interp_points, interp_points)) image (interp_points, interp_points, matrix (interp_bilinear, 200, 200))  

linear interpolation

  #Bicube Interpolation Library ( Aakima) Interp_Abiquic & lt; - BIQubic.Grid (X, Y, Z, Eclaim = C (-2, 0), Yelmu = C (-2, 0), DX = 2 / (200 - 1), DI = 2 / (200 - 1) ) Image (Interp_bicubic)  

bicubic interpolation

The difference between different project plans becomes clear when you have less observation or more wildly behaviors:


Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -