0
$\begingroup$

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

f[x,y]=Piecewise[{{Blue,0<y<Pi},{Yellow,Pi<y<2Pi}}]

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.

$\endgroup$
4
$\begingroup$

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
  ]

Row[{
  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.

RevolutionPlot3D[
 {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.

$\endgroup$
  • $\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$ – Salvatore Baldino Sep 29 '16 at 19:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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