Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Contour plots on a sphere surface

Tags:

r

contour

I have acquired some data at a fixed distance R and for various theta (from the vertical axis) and phi (from the x axis) angles so to obtain a 3D representation of the quantity of interest. Please note that while phi spans 360°, theta only spans from 70° to 90°.

I know how to generate a 3D plot with the plot3D package (namely, the persp3D function) or a contour plot, but I would like to draw such contours over a sphere using the theta and phi angles information.

Would you please point me to the appropriate online resource where I can find a suitable solution?

Many thanks and kind regards

Nicola

like image 467
Nicola Pasquino Avatar asked Jul 27 '15 12:07

Nicola Pasquino


People also ask

How do you plot in 3D contour?

To plot 3D contour we will use countour3() to plot different types of 3D modules. Syntax: contour3(X,Y,Z): Specifies the x and y coordinates for the values in Z. contour3(Z): Creates a 3-D contour plot containing the isolines of matrix Z, where Z contains height values on the x-y plane.

How do you plot a 3D contour plot in Matlab?

Define Z as a function of X and Y . In this case, call the sphere function to create X , Y , and Z . Then plot the contours of Z . [X,Y,Z] = sphere(50); contour3(X,Y,Z);

What does a contour plot tell you?

Interpreting Contour Plots and Finding Combinations that Produce Good Outcomes. Use a contour plot to explore the relationship between three variables. These plots display two independent variables (X, Y) and one dependent variable (Z). Contour plots help identify combinations that yield beneficial outcome values.

What is contour plot in RSM?

A contour plot is the geometric illustration of a 3-D relationship in two dimensions, with X1 and X2 (independent variables) plotted on x- and y-scales and response values represented by contours (z-scale). Contour plots are useful for establishing the response values and operating conditions as required.


1 Answers

This isn't exactly a 3d representation (e.g. in rgl), but maybe it gets you started:

library(maps)
library(mapproj)        
library(akima)

set.seed(11)
n <- 500
x <- runif(n, min=-180,max=180)
y <- runif(n, min=-90,max=90)
z <- x^2+y^3

PARAM <- NULL
PROJ <- "orthographic"
ORIENT <- c(45,15,0)
XLIM <- c(-180, 180)
YLIM <- c(-90, 90)

nlevels=20
pal <- colorRampPalette(
  c("purple4", "blue", "cyan", "yellow", "red", "pink"))
map("world", col=NA, param=PARAM, proj=PROJ, orient=ORIENT, xlim=XLIM, ylim=YLIM)
P <- mapproject(x,y)
incl <- which(!is.na(P$x))
Field <- interp(P$x[incl],P$y[incl],z[incl],
  xo=seq(min(P$x[incl]), max(P$x[incl]), length = 100),
  yo=seq(min(P$y[incl]), max(P$y[incl]), length = 100)
)
image(Field, add=TRUE, col=pal(nlevels))
points(P$x, P$y, pch=".", cex=2, col=4)
Cont <- contour(Field, add=TRUE, n=nlevels, col="white")
lines(sin(seq(0,2*pi,,100)), cos(seq(0,2*pi,,100)), lwd=3)

enter image description here

like image 154
Marc in the box Avatar answered Sep 21 '22 18:09

Marc in the box