my first question here. I'm totally new at graphing with Mathematica, and my general knowledge of Mathematica is not so good either.

I'm trying to replicate the drawings in Manton, Classical Skyrmions, page 5. I'd try to do that through a function of the polar angles, that assigns a color to a certain coordinate. I'm not trying to recreate any hue, I'd just be contented with a sphere with a limited number of colors.

In short, I'd like to assign colors to a sphere through a function like


where x and y are spherical angles, with y azimutal and x polar. I've read through much of the obvious documentation in understanding how to implement this idea, but so far no luck.

After drawing such spheres, I'd also like to understand how to rotate them, to draw pictures like two spheres oriented differently (where the orientation is defined through the coloring).

I'm very confused about the documentation, in particular from where to start. I'd like to have some suggestions about where to search for a guide about this type of things.

I thank you in advance.


1 Answer 1


You should start by looking at the plotting commands. First; how can you draw a sphere? Secondly; how can you color it?

Method 1

Plot the parts separately and put them together.

sphere[t1_, t2_, col_] := RevolutionPlot3D[
  {Cos[t], Sin[t]}, {t, t1, t2},
  Mesh -> None, PlotStyle -> col,
  ImageSize -> 200

  sphere[-Pi/2, 0, Blue],
  sphere[0, Pi/2, Yellow],
  Show[sphere[-Pi/2, 0, Blue], sphere[0, Pi/2, Yellow], 
   PlotRange -> All]

Mathematica graphics

Method 2

Use ColorFunction, which is an option that's available for many plotting commands.

 {Cos[t], Sin[t]},
 {t, -Pi/2, Pi/2},
 Mesh -> None,
 ColorFunction -> Function[{x, y, z, t, th, r},
   If[-Pi/2 < t < 0, Blue, Yellow]
 ColorFunctionScaling -> False,
 ImageSize -> 200

Mathematica graphics

There are other examples in the documentation, under Options -> ColorFunction.

How to rotate the sphere

You also asked about rotating the sphere, but if the sphere is the only thing in your image then it can be easier to rotate the view. See for example ViewPoint. Otherwise it's just a matter of changing the math, or possibly some method using Rotate.

  • $\begingroup$ Thank you, the second method is exactly what I wanted. About the rotation issue, the fact is that I also want to plot more than one sphere with different relative color orientations. But rotating the color function seems the way to go, I'll try it. $\endgroup$ Sep 29, 2016 at 19:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.