Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #8044 > unrolled thread

VectorColorFunction

Started byPeter Rodenbach <peter.rodenbach@googlemail.com>
First post2012-01-20 07:00 +0000
Last post2012-01-21 10:16 +0000
Articles 3 — 2 participants

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  VectorColorFunction Peter Rodenbach <peter.rodenbach@googlemail.com> - 2012-01-20 07:00 +0000
    Re: VectorColorFunction Dan <dflatin@rcn.com> - 2012-01-21 10:16 +0000
    Re: VectorColorFunction Dan <dflatin@rcn.com> - 2012-01-21 10:16 +0000

#8044 — VectorColorFunction

FromPeter Rodenbach <peter.rodenbach@googlemail.com>
Date2012-01-20 07:00 +0000
SubjectVectorColorFunction
Message-ID<jfb3dr$hu0$1@smc.vnet.net>
Hi experts,

I want to plot via ListVectorPlot a Field of Vectors. I obtained the
vectors from a physics experiment. The Norm of all vectors is very
similar, and what is important is its direction!

Therefore, what I want to do now is: give each vector a color with a
different direction a different color, e.g., up to 0.5degree red, 0.5
to 1 degree yellow, etc.

The Problem: The norm of each vector is used as argument for the
function that determines the color, according to the help

"With the setting VectorColorFunction->func, the arguments supplied to
func are as follows" ,...., x,y,Subscript[v, x],Subscript[v,
y],Norm[{Subscript[v, x],Subscript[v, y]}]"

Does anyone have an idea for a workaround?

Thanks

Peter

[toc] | [next] | [standalone]


#8050

FromDan <dflatin@rcn.com>
Date2012-01-21 10:16 +0000
Message-ID<jfe39p$9sh$1@smc.vnet.net>
In reply to#8044
On Jan 20, 2:00 am, Peter Rodenbach <peter.rodenb...@googlemail.com>
wrote:
> Hi experts,
>
> I want to plot via ListVectorPlot a Field of Vectors. I obtained the
> vectors from a physics experiment. The Norm of all vectors is very
> similar, and what is important is its direction!
>
> Therefore, what I want to do now is: give each vector a color with a
> different direction a different color, e.g., up to 0.5degree red, 0.5
> to 1 degree yellow, etc.
>
> The Problem: The norm of each vector is used as argument for the
> function that determines the color, according to the help
>
> "With the setting VectorColorFunction->func, the arguments supplied to
> func are as follows" ,...., x,y,Subscript[v, x],Subscript[v,
> y],Norm[{Subscript[v, x],Subscript[v, y]}]"
>
> Does anyone have an idea for a workaround?
>
> Thanks
>
> Peter

One solution is to take the output of ListVectorPlot and with a
ReplaceAll and a Rule prepend each Arrow with a color, e.g.

directionHue[{p1_,p2_}]:=Hue[Rescale[ArcTan@@(p2-p1),{-\[Pi],\[Pi]}]];
data=Table[{Sin[x],Cos[y]},{x,-2,2,0.1},{y,-2,2,0.1}];
ListVectorPlot[data]/.Arrow[pts_]->{directionHue@pts,Arrow@pts}

Here I have a continous color function based on direction. It can be
easily modified to return one of a discrete set of colors based on
angle range.

-- Dan

[toc] | [prev] | [next] | [standalone]


#8070

FromDan <dflatin@rcn.com>
Date2012-01-21 10:16 +0000
Message-ID<jfe3ap$9sr$1@smc.vnet.net>
In reply to#8044
On Jan 20, 2:00 am, Peter Rodenbach <peter.rodenb...@googlemail.com>
wrote:
> Hi experts,
>
> I want to plot via ListVectorPlot a Field of Vectors. I obtained the
> vectors from a physics experiment. The Norm of all vectors is very
> similar, and what is important is its direction!
>
> Therefore, what I want to do now is: give each vector a color with a
> different direction a different color, e.g., up to 0.5degree red, 0.5
> to 1 degree yellow, etc.
>
> The Problem: The norm of each vector is used as argument for the
> function that determines the color, according to the help
>
> "With the setting VectorColorFunction->func, the arguments supplied to
> func are as follows" ,...., x,y,Subscript[v, x],Subscript[v,
> y],Norm[{Subscript[v, x],Subscript[v, y]}]"
>
> Does anyone have an idea for a workaround?
>
> Thanks
>
> Peter

Another solution, using VectorColorFunction:

directionHue={x,y,vx,vy,n}\[Function]Hue[Rescale[ArcTan[vx,vy],{-\[Pi],
\[Pi]}]];
data=Table[{Sin[x],Cos[y]},{x,-2,2,0.1},{y,-2,2,0.1}];
ListVectorPlot[data,
  VectorColorFunction->directionHue,
  VectorColorFunctionScaling->False
]

-- Dan

[toc] | [prev] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web