MathGroup Archive 2011

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: AxesLabel parallel to 3D axes?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg118843] Re: AxesLabel parallel to 3D axes?
  • From: Fred Klingener <jfklingener at gmail.com>
  • Date: Fri, 13 May 2011 06:25:08 -0400 (EDT)
  • References: <i2rm0a$r4c$1@smc.vnet.net> <i33cph$81k$1@smc.vnet.net> <iqg5th$d0t$1@smc.vnet.net>

On May 12, 4:31 am, "Christopher O. Young" <c... at comcast.net> wrote:
> Isn't there some way to paste images onto surfaces in 3D views? Then, if we
> could just have a flat rectangle with an image of the label on it, we'd be
> all set. Especially if the rectangle could be transparent while the
> lettering on it could be kept opaque.
...
Probably the best way now, if you are using version 8 is to compose an
image of your label and apply it as a Texture to a Polygon sized and
located where you want it.

>From the Doc Center, with some explicit changes to accommodate
extended range for axis labels and the clearing of box and axes:

p3d = Plot3D[Sin[x y], {x, 0, 3}, {y, 0, 3},
   ColorFunction -> "Rainbow", Mesh -> None,
   PlotRange -> {{-.2, 3.2}, {-0.2, 3.2}, {-1, 1}}, Boxed -> False,
   Axes -> False];

(* I'll compose a label for the x axis: *)

xaxis = Style[
   " x axis "
   , FontFamily -> "Helvetica"
   , 12
   , Bold
   ];

(* There seem to be a lot of acceptable ways to get this into a form \
ready for Texture,but explicitly building a Raster is the only way \
I've found to control the size, resolution and aspect ratio. *)

xraster = Rasterize[
   xaxis
   , ImageResolution -> 300
   , Background -> None
   , ColorSpace -> "Grayscale"
   ];

aspect = Divide @@ Rasterize[xraster, "RasterSize"];

(*Draw a host polygon,centered at*)

center = {1.5, -0.15, 0.};

(*and a height in the y direction of *)

h = 0.15;

(* The Polygon corners are *)

pts = (center + h/2*#) & /@ {{-aspect, -1., 0.}, {aspect, -1,
     0.}, {aspect, 1, 0.}, {-aspect, 1., 0.}};

(* ,and the Polygon becomes *)

poly = Polygon[
   pts
   , VertexTextureCoordinates -> {
     {0, 0, 0}
     , {1, 0, 0}
     , {1, 1, 0}
     , {0, 1, 0}
     }];

(* The assembly becomes: *)

Show[{
  p3d
  , Graphics3D[{
    Texture[xraster]
    , EdgeForm[None]
    , poly
    }]
  }]

The result doesn't meet your requirement for transparency of the
background, but none of the more obvious approaches seems to work. The
Texture machinery is evidently connected tightly to the FaceForm[]
machinery, so none of the Background or Opacity angles appear to work.
It seems essential that the Raster should have an alpha (opacity)
channel, and the Background->None ought to be the way to get it. But
it doesn't.

Setting the Style Background to be the same as p3d Background makes
the label background appear transparent, but there are some roundoff
errors that get in the way of that.

Mathematica still needs a good Text3D.

Hth,
Fred



  • Prev by Date: Re: OptionsPattern[...]
  • Next by Date: Re: How to select all cells in a notebook with specific property?
  • Previous by thread: Re: OptionsPattern[...]
  • Next by thread: Re: AxesLabel parallel to 3D axes?