       Re: Give arrow a certain color

• To: mathgroup at smc.vnet.net
• Subject: [mg104788] Re: Give arrow a certain color
• From: Albert Retey <awnl at gmx-topmail.de>
• Date: Tue, 10 Nov 2009 05:58:16 -0500 (EST)
• References: <hd8rv7\$5l8\$1@smc.vnet.net>

```Hi,

> we discussed recently how to make curved arrows. Here is an example:
>
> r[t_] := Exp[-t];
> \[Theta][t_] := 3 t + 0.7;
>
> pl1 = ReplacePart[
>    ParametricPlot[{r[t]*Cos[\[Theta][t]], r[t]*Sin[\[Theta][t]]}, {t,
>      0, 1.1}, Ticks -> None, AxesLabel -> {"z", "z'"},
>     PlotRange -> {-1, 1}], {1, 1, 3, 2, 0} -> Arrow];
> pl2 = ParametricPlot[{r[t]*Cos[\[Theta][t]],
>     r[t]*Sin[\[Theta][t]]}, {t, 1, 7}, Ticks -> None,
>    AxesLabel -> {"z", "z'"}, PlotRange -> {-1, 1}];
>
> Show[{pl1, pl2}]
>
> However, I cannot force Mathematica to make the graph black (or any other color) instead of blue. The option PlotStyle->Black as below
>
> ReplacePart[
>  ParametricPlot[{r[t]*Cos[\[Theta][t]], r[t]*Sin[\[Theta][t]]}, {t, 0,
>     1.1}, PlotStyle -> Black, Ticks -> None, AxesLabel -> {"z", "z'"},
>    PlotRange -> {-1, 1}], {1, 1, 3, 2, 0} -> Arrow]
>
> does not work.
>
>
> Could you please give me a hint, of how to do this?

I think this is a good example why it is many cases a bad idea to refer
to parts of expressions by position, especially when the expressions are
generated automatically and even more when they are graphics, where e.g.
a leading {} will change all positions but leave the graphics unchanged.

The construct you used is also very likely to be broken with another
version of mathematica, because the probablility that the Line you are
changing to be an Arrow will still appear at position 1,1,3,2,0 after
any change in the function definition is rather low.

The additional style information will just change the exact position of
the line within the Graphics expression. Specifying another style
directive will change it again. Not something you want to deal with. So
it is better to use real pattern matching to do the replacement, e.g.
the following will work for this simple example:

ReplaceAll[
ParametricPlot[
{r[t]*Cos[\[Theta][t]], r[t]*Sin[\[Theta][t]]}, {t, 0,1.1},
PlotStyle -> Black, Ticks -> None,
AxesLabel -> {"z", "z'"},PlotRange -> {-1, 1}
],
Line -> Arrow
]

It might be necessary to use a more restrictive pattern than that if
there are more than one line and you only want to replace one of them to
an arrow. You could e.g. replace only lines that start or/and end at a
certain coordinate or have a certain length, etc...

hth,

albert

```

• Prev by Date: Re: Give arrow a certai color
• Next by Date: Re: Ten chess-players...
• Previous by thread: Re: Ten chess-players...
• Next by thread: Re: Plotting with dotted lines solved (Re: