[Date Index]
[Thread Index]
[Author Index]
Re: Colored Tick Labels?
*To*: mathgroup at smc.vnet.net
*Subject*: [mg66928] Re: Colored Tick Labels?
*From*: bghiggins at ucdavis.edu
*Date*: Sun, 4 Jun 2006 01:10:16 -0400 (EDT)
*References*: <e5reku$h2e$1@smc.vnet.net>
*Sender*: owner-wri-mathgroup at wolfram.com
Not sure I have a complete answer, but here are some possibilities to
examine:
Suppose you have the following plot
plt = Plot[Sin[x], {x, -1, 1}]
You can extract the Ticks from this plot using AbsoluteOptions and then
modify them. In the following example I make the x tick values Blue and
the y tick values Red
myTicks = {(Ticks /. AbsoluteOptions[plt,
Ticks])[[1]] /. {x_Real, y_Real, z__} -> {x, StyleForm[y,
FontColor -> Blue], z}, (Ticks /. AbsoluteOptions[plt,
Ticks])[[
2]] /. {x_Real, y_Real, z__} -> {x,
StyleForm[y, FontColor -> Red], z}}
The following plot has the colored ticks
Plot[Sin[x], {x, -1, 1}, Ticks -> myTicks]
In the same way one can write code to not only change the tick colors
but also alter the values displayed. If you do not have the original
Ticks option for your plot, then you have to construct them yourself
xTicks = {{-1, A}, {0.0, 0}, {1, B}};
xColorTicks = Map[{#[[1]], StyleForm[#[[2]], FontColor -> Red]} &,
xTicks];
Plot[Sin[x], {x, -1, 1}, Ticks -> {xColorTicks, Automatic}]
Now if you you want to generate the ticks without access to the plot
graphic object, you can write your own Tick function as follows
TickPosition[x0_Real, x1_Real, num_Integer?
Positive] := Module[{delta},
delta= (x1 - x0)/(num - 1);
Table[{x, StyleForm[x, FontColor -> Red]}, {x, x0, x1, delta}]]
plt = Plot[Sin[x], {x, -3, 3}, Ticks -> {TickPosition[#1, #2, 7] &,
Automatic}]
The above TickPosition function is quite crude, but is does take as its
augments the values from the plot range. See Tom Wickham-Jones book
Mathematica Graphics for ways to spruce up your TickPosition function
I do not know away to autimatically set the color of the tick labels.
Hope this helps,
Cheers,
Brian
AES wrote:
> 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?
Prev by Date:
**Re: Homotopic algorithm to solve a system of equations**
Next by Date:
**Re: tensors, matrices, and rotation**
Previous by thread:
**Re: Colored Tick Labels?**
Next by thread:
**Re: Re: Colored Tick Labels?**
| |