Re: Scale Values on Plot[]
- To: mathgroup at smc.vnet.net
- Subject: [mg51349] Re: [mg51294] Scale Values on Plot[]
- From: "David Park" <djmp at earthlink.net>
- Date: Fri, 15 Oct 2004 02:45:42 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
Jeremy, You can use the Tick, or FrameTicks with a Frame, option. One method is just to make a simple table of the tick locations and values. Plot[Sin[x], {x, -Pi, Pi}, Frame -> True, FrameTicks -> {Table[{v, v}, {v, -Pi, Pi, Pi/2}], Automatic, Table[{v, ""}, {v, -Pi, Pi, Pi/2}], Automatic}, Axes -> False, ImageSize -> 450]; A second method is to use the PiScale routine from the standard package Graphics`Graphics`. (There is also a LogScale and LinearScale. Use ?*Scale for information.) Needs["Graphics`Graphics`"] Plot[Sin[x], {x, -Pi, Pi}, Frame -> True, FrameTicks -> {PiScale, Automatic, None, Automatic}, Axes -> False, ImageSize -> 450]; This, however, has the slight disadvantage of not providing matching but unlabeled ticks on the top of the frame. If you use PiScale where None is you get the values again and if you use Automatic you get unmatching tick marks. One could revert to the Table. It would be much better if Graphics`Graphics` had an option in PiScale for displaying or not displaying the values. If you are using Axes instead of a Frame this is not a problem. But labeled Axes are not great if they run through the middle of a plot. If you use the DrawGraphics package from my web site below, there is a CustomTicks function that allows more flexibility including using a function to transform the plot coordinate values to tick values and an option to control the number formatting - here used to suppress the labels on the top of the frame. I was able to specify large labeled and small unlabeled ticks on the bottom of the frame and large and small unlabeled ticks on the top of the frame. PiScale doesn't allow that and it's a lot more work to specified large and small ticks with a Table specification. Needs["DrawGraphics`DrawingMaster`"] Draw2D[ {Draw[Sin[x], {x, -Pi, Pi}]}, Frame -> True, FrameTicks -> {CustomTicks[Identity, {-Pi, Pi, Pi/2, 2}], Automatic, CustomTicks[Identity, {-Pi, Pi, Pi/2, 2}, CTNumberFunction -> ("" &)], Automatic}, ImageSize -> 450 David Park djmp at earthlink.net http://home.earthlink.net/~djmp/ From: Jeremy Foster [mailto:jeremyrfoster at hotmail.com] To: mathgroup at smc.vnet.net I would like to plot the simple function of Sin[x] but have the x axis labels be -Pi, -Pi/2, 0, Pi/2, Pi instead of integer values 1, 2, 3, etc. Is this possible? Jeremy Foster