RE: Colored Tick Labels?
- To: mathgroup at smc.vnet.net
- Subject: [mg66941] RE: [mg66910] Colored Tick Labels?
- From: "David Park" <djmp at earthlink.net>
- Date: Sun, 4 Jun 2006 02:01:17 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
With DrawGraphics one could use the CustomTicks command. The following plots Sin[Pi t] from -1 to 1, then relabels the x axis so it runs from -Pi to Pi and also multiplies the amplitude of the curve by 3 and shifts it up by three so the y scale goes from 0 to 6. The x-axis labels are in red and the y axis labels are in blue. One only has to enter StyleForm once, in the CTNumberFunction option. We also obtain the unlabeled subdivision ticks and for the top and right frame ticks we have the same divisions with no tick labels. Just for fun, I also added very light grid lines using CustomGridLines. The pure functions take us from the tick label to the underlying plot value. The list gives us {start, end, step, number of subdivisions} in terms of the labeled tick values. Needs["DrawGraphics`DrawingMaster`"] xticks = CustomTicks[#/Pi &, {-Pi, Pi, Pi/2, 5}, CTNumberFunction -> (StyleForm[#, FontColor -> Red] &)]; topticks = CustomTicks[#/Pi &, {-Pi, Pi, Pi/2, 5}, CTNumberFunction -> ("" &)]; yticks = CustomTicks[(# - 3)/3 &, {0, 6, 1, 5}, CTNumberFunction -> (StyleForm[#, FontColor -> Blue] &)]; rightticks = CustomTicks[(# - 3)/3 &, {0, 6, 1, 5}, CTNumberFunction -> ("" &)]; xgrids = CustomGridLines[#/Pi &, {-Pi, Pi, Pi/2}, {Gainsboro}]; ygrids = CustomGridLines[(# - 3)/3 &, {0, 6, 1}, {Gainsboro}]; Draw2D[ {Draw[Sin[Pi t], {t, -1, 1}]}, Frame -> True, FrameTicks -> {xticks, yticks, topticks, rightticks}, GridLines -> {xgrids, ygrids}, ImageSize -> 450]; David Park djmp at earthlink.net http://home.earthlink.net/~djmp/ From: AES [mailto:siegman at stanford.edu] To: mathgroup at smc.vnet.net To create frames with different scales and tick labels on each axis, I habitually use syntax like: xTicks={{-1,"-Pi"}, {0.5,"0"}, {1,"Pi"}} and so on, and then FrameTicks->{xTicks, yTicks, topTicks, rightTicks} Question: Any simple way to apply a different color to the set of ticks on each axis ***without having to insert a syntax like StyleForm["-Pi", FontColor->Red] into each and every individual quoted "-Pi" label separately?