MATLAB: How to project the 2-dimensional contour plot onto a sphere in MATLAB

3 dimensional3-dcontourMATLABspherical

I have created a 2-dimensional contour plot using the CONTOUR function. Now I want to convert this plot into spherical coordinates, i.e., project the contour lines onto a sphere.

Best Answer

The ability to project contour lines onto a sphere is not available in MATLAB through any built-in functions.
However, with some computations and careful bookkeeping, you can accomplish this, as the attached example illustrates. This file creates a 2-dimensional contour plot, then regenerates it by using the information extracted from the first plot (to demonstrate how the x- and y-coordinates can be read and what they mean), and finally computes the new 3-dimensional lines and plots them on a sphere, preserving all the original colors.