From: David Reiss on
If one sets the AxesLabel option for, for example, Plot3D, is there
any way to set things up so that resulting labels are always parallel
to their own axes?

....here is an example, and a customer would like the labels to align
along/paralle the axes rather than what is shown here....

Plot3D[x y, {x, 0, 1}, {y, 0, 1},
AxesLabel -> {"This is the x", "This is the y", "This is the z"}]


From: Bob Hanlon on

If the ViewPoint is not allowed to change:

labels = {
Rotate["This is the x", -20 Degree],
Rotate["This is the y", 60 Degree],
Rotate["This is the z\n", 95 Degree]};

Plot3D[x y, {x, 0, 1}, {y, 0, 1},
AxesLabel -> labels]


Bob Hanlon

---- David Reiss <dbreiss(a)gmail.com> wrote:

=============
If one sets the AxesLabel option for, for example, Plot3D, is there
any way to set things up so that resulting labels are always parallel
to their own axes?

....here is an example, and a customer would like the labels to align
along/paralle the axes rather than what is shown here....

Plot3D[x y, {x, 0, 1}, {y, 0, 1},
AxesLabel -> {"This is the x", "This is the y", "This is the z"}]



From: Murray Eisenberg on
But -- at least on my 1600x1200 monitor, Windows XP, the axes labels now
have considerably degraded resolution and therefore look quite awful.

However, if I then export the plot to pdf and view the latter, the
labels look just fine!

On 7/30/2010 6:55 AM, Bob Hanlon wrote:
> If the ViewPoint is not allowed to change:
>
> labels = {
> Rotate["This is the x", -20 Degree],
> Rotate["This is the y", 60 Degree],
> Rotate["This is the z\n", 95 Degree]};
>
> Plot3D[x y, {x, 0, 1}, {y, 0, 1},
> AxesLabel -> labels]
>
>
> Bob Hanlon
>
> ---- David Reiss<dbreiss(a)gmail.com> wrote:
>
> =============
> If one sets the AxesLabel option for, for example, Plot3D, is there
> any way to set things up so that resulting labels are always parallel
> to their own axes?
>
> ...here is an example, and a customer would like the labels to align
> along/paralle the axes rather than what is shown here....
>
> Plot3D[x y, {x, 0, 1}, {y, 0, 1},
> AxesLabel -> {"This is the x", "This is the y", "This is the z"}]
>
>
>

--
Murray Eisenberg murray(a)math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower phone 413 549-1020 (H)
University of Massachusetts 413 545-2859 (W)
710 North Pleasant Street fax 413 545-1801
Amherst, MA 01003-9305

From: David Park on
If one can accept having labels inside the bounding box, then the following
is a solution independent of the ViewPoint. The labels stay parallel to the
axes no matter how the image is rotated with the mouse.

Needs["Presentations`Master`"]

Draw3DItems[
{Draw3D[x y, {x, 0, 1}, {y, 0, 1}],
Black,
VerticalText3D[
Style["This is x", FontFamily -> "Helvetica"], {0.5, 0, -0.05},
0 \[Degree], .07 {1.5, 1}],
VerticalText3D[
Style["This is y", FontFamily -> "Helvetica"], {1.0, 0.5,
0. - 0.05}, 90 \[Degree], .07 {1.5, 1}],
Text3D[Style["This is z", FontFamily -> "Helvetica"], {-0.0, -0.0,
0.5}, -180 \[Degree], {1, 0, 0}, .07 {1.5, .7}]},
NiceRotation,
PlotRange -> {{0, 1}, {0, 1}, {-0.1, 1}},
PlotRangePadding -> 0.05,
BoxRatios -> {1, 1, .5},
Axes -> True,
AxesEdge -> {{-1, -1}, {1, -1}, {-1, -1}},
ViewPoint -> 2 {1, -1, .25},
ImageSize -> 1.2 {400, 350}]

Of course with true 3D labels when you rotate the image the labels also
rotate and sometimes may be seen edgewise, or backward, or partially hidden
by the surface.


David Park
djmpark(a)comcast.net
http://home.comcast.net/~djmpark/



From: Murray Eisenberg [mailto:murray(a)math.umass.edu]

But -- at least on my 1600x1200 monitor, Windows XP, the axes labels now
have considerably degraded resolution and therefore look quite awful.

However, if I then export the plot to pdf and view the latter, the
labels look just fine!

On 7/30/2010 6:55 AM, Bob Hanlon wrote:
> If the ViewPoint is not allowed to change:
>
> labels = {
> Rotate["This is the x", -20 Degree],
> Rotate["This is the y", 60 Degree],
> Rotate["This is the z\n", 95 Degree]};
>
> Plot3D[x y, {x, 0, 1}, {y, 0, 1},
> AxesLabel -> labels]
>
>
> Bob Hanlon
>
> ---- David Reiss<dbreiss(a)gmail.com> wrote:
>
> =============
> If one sets the AxesLabel option for, for example, Plot3D, is there
> any way to set things up so that resulting labels are always parallel
> to their own axes?
>
> ...here is an example, and a customer would like the labels to align
> along/paralle the axes rather than what is shown here....
>
> Plot3D[x y, {x, 0, 1}, {y, 0, 1},
> AxesLabel -> {"This is the x", "This is the y", "This is the z"}]
>
>
>

--
Murray Eisenberg murray(a)math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower phone 413 549-1020 (H)
University of Massachusetts 413 545-2859 (W)
710 North Pleasant Street fax 413 545-1801
Amherst, MA 01003-9305



From: Fred Klingener on
On Jul 29, 6:43 am, David Reiss <dbre...(a)gmail.com> wrote:
> If one sets the AxesLabel option for, for example, Plot3D, is there
> any way to set things up so that resulting labels are always parallel
> to their own axes?
>
> ...here is an example, and a customer would like the labels to align
> along/paralle the axes rather than what is shown here....
>
> Plot3D[x y, {x, 0, 1}, {y, 0, 1},
> AxesLabel -> {"This is the x", "This is the y", "This is the z"}]

I've used a couple of approaches to this, a raster and a vector. The
vector form is much faster, looks far better, but is a hack, based on
undocumented features. I don't think I'd use it on anything critically
important.

The first resolves the styled text to a Raster, applies raster point
properties to a flat 3D grid of square Polygons, then orients and
places it in the scene using 3D transformations. Here's a sketch

fontSize = 14;
imageResolution = 75; (* dpi, say *)

imgData =
Rasterize[
Style[
"hello,world."
, FontFamily -> "Helvetica"
, Bold
, FontSize -> fontSize]
(* give back just the raster data *)
, "Data"
(* pick an image resolution for the application *)
, ImageResolution -> imageResolution
(* The combination of the next two option settings produces an
array of 2-
Lists with the form {gray, alpha} each in the range {0, 255} *)
, Background -> None
, ColorSpace -> "Grayscale"];

d = Dimensions[imgData]

The next line is required to shuffle the rows of the raster and
convert the byte values {0, 255} from the Rasterize to the {0., 1.}
required for use in GrayLevel[]

imgData2 = Reverse[imgData/255.];

This constructs a 2D grid in the x-y plane of square 3D Polygons with
FaceForms derived from the Raster.

polyGray3D =
Table[
Table[
{
FaceForm[
GrayLevel[imgData2[[j + 1, i + 1]]]
]
, Polygon[{
{i, j, 0.}
, {i + 1, j, 0.}
, {i + 1, j + 1, 0.}
, {i, j + 1, 0.}
}]
}
, {i, 0, d[[2]] - 1}]
, {j, 0, d[[1]] - 1}];

Then the Polygon grid can be scaled (maybe using imageResolution) and
placed in a scene. I'll apply a Background to make sure that works
right.

Graphics3D[{
Cuboid[{0, 0, 0}, {1, 1, 1}]
, EdgeForm[None]
(* Translate a bit in the y direction *)
, Translate[
(* and rescale to inches *)
Scale[
polyGray3D
, 1/imageResolution
, {0, 0, 0}
]
, {0., -0.25, 0}
]
}
, Axes -> True
, AxesOrigin -> 0
, Background -> Blue
, PlotRange -> {{-.2, 1.2}, {-.5, 1.2}, {-0.2, 1.2}}
]

______________________

The second approach exploits the Export/Import mechanism, using the
"PDF' mode to generate a vector representation of the letter forms.

vectorImg =
First@
First@
ImportString[
ExportString[

Style[
"hello,world."
, FontFamily -> "Helvetica"
, Bold
, FontSize -> fontSize
, ShowStringCharacters -> False
]

, "PDF"
, ShowStringCharacters -> False
]
, "PDF"
];
Graphics[vectorImg, Axes -> True]

vectorImage is composed of 2D Polygons, which represent the letter
forms. The scale is evidently somewhere around printer points (1/72
inch).

Stripping out everything but the Polygons from vectorImage still
leaves a complete rendering of the text.

Graphics[polygons2D = Cases[vectorImg, _Polygon, Infinity]]

These polygons can be converted to 3D Polygons oriented any way we
like, but laying them on the x-y plane is as good as any.

Graphics3D[{
Cuboid[{0, 0, 0}, {1, 1, 1}]
, EdgeForm[None]
, FaceForm[Black]
(* Translate a bit in the y direction *)
, Translate[
(* and rescale from points to inches *)
Scale[
polygons2D /. {x_, y_} :> {x, y, 0.}
, 1/72
, {0, 0, 0}
]
, {0., -0.25, 0}
]
}
, Axes -> True
, AxesOrigin -> 0
, Background -> Blue
, PlotRange -> {{-.2, 1.2}, {-.5, 1.2}, {-0.2, 1.2}}
]

Decent built-in 3D text is long overdue in Mathematica. I think.

Hth,
Fred Klingener