Re: Label Display in 2-D Plots?
- To: mathgroup at smc.vnet.net
- Subject: [mg13735] Re: Label Display in 2-D Plots?
- From: "Allan Hayes" <hay at haystack.demon.cc.uk>
- Date: Wed, 19 Aug 1998 01:38:25 -0400
- References: <6r110o$fkd@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Stefan Jeglinski wrote in message <6r110o$fkd at smc.vnet.net>...
>I do not want the axes labels to be positioned at the ends of the axes.
>There seem to be no options here. I have tried frame labels as well.
>The frame label which appears below the horizontal axis is
>satisfactory, but I want the vertical axis label to be written
>vertically, as is common in published work. I seem to be not able to do
>this with frame labels. In addition, I find the frame label along the
>vertical axis to be too close to the numbers, but I can't nudge it out.
>Finally, I tried making text objects but I cannot seem to be able to
>superimpose them onto graphics already created.
Stefan,
Here are some experiments that may help. You will find information about
the various objects used in the Help browser.
1) Vertical "y-axis"label, half way up the axis.
(Default value of option RotateLabel is True)
Show[Graphics[{Line[{{0, 0}, {1, 1}}],
Text["y axis",Scaled[{-.12,.5}],{0,0},{0,1}]}], Axes->True,
PlotRegion ->{{.15,1},{0,1}} (*create space for label*) ]
2) Vertical label half way up left of frame.
Show[
Graphics[{Line[{{0, 0}, {1, 1}}]}],
Frame->True,
FrameLabel ->"y axis"
]
3) Nudging the label in 2) away from the axis and coloring "y" red
Type y axis in an input cell; color y red (menu > Format > TextColor)
select all of the text in the cell and use menu > Edit > Input > Nudge
Up (or keyboard equivalent) to nudge upwards.
Look at the cell exression:
Cell[BoxData[
AdjustmentBox[
RowBox[{
StyleBox["y",
FontColor->RGBColor[1, 0, 0]], " ", "axis"}],
BoxMargins->{{0, 0}, {1.5, -1.5}},
BoxBaselineShift->-1.5]], "Input"]
The crucial part is AdjustmentBox[..]
Define
txt = AdjustmentBox[
RowBox[{
StyleBox["y",
FontColor->RGBColor[1, 0, 0]], " ", "axis"}],
BoxMargins->{{0, 0}, {1.5, -1.5}},
BoxBaselineShift->-1.5]]
Look at
Show[
Graphics[{Line[{{0, 0}, {1, 1}}]}],
Frame->True,
FrameLabel ->DisplayForm[txt ],
PlotRegion ->{{.05,.97},{0,1}} (*create space for label*) ]
4) Adding text
Show[Graphics[{Line[{{0, 0}, {1, 1}}]}], Graphics[Text["text",
{.5,.5}]]]
Show[Graphics[{Line[{{0, 0}, {1, 1}}], Text["text", {.5,.5}]}]]
Show[Graphics[{Line[{{0, 0}, {1, 1}}]}], Epilog ->Text["text", {.3,.5}]]
Allan,
------------------------------------------------------------- Allan
Hayes
Training and Consulting
Leicester UK
http://www.haystack.demon.co.uk
hay at haystack.demon.co.uk
voice: +44 (0)116 271 4198
fax: +44(0)116 271 8642