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


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

Re: Plotting a line with color changing as a function of position

Started byBob Hanlon <hanlonr357@gmail.com>
First post2012-01-14 22:13 +0000
Last post2012-01-14 22:13 +0000
Articles 1 — 1 participant

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

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Plotting a line with color changing as a function of position Bob Hanlon <hanlonr357@gmail.com> - 2012-01-14 22:13 +0000

#7822 — Re: Plotting a line with color changing as a function of position

FromBob Hanlon <hanlonr357@gmail.com>
Date2012-01-14 22:13 +0000
SubjectRe: Plotting a line with color changing as a function of position
Message-ID<jesulk$cig$1@smc.vnet.net>
y[x_, {x1_, y1_}, {x2_, y2_}] =
  ((y2 - y1)*x + x2*y1 - x1*y2)/(x2 - x1);

p1 = {0, 0}; p2 = {10, 10};

Plot[y[x, p1, p2], {x, 0, 10},
 ColorFunction ->
  Function[{x, y}, Hue[Cos[Norm[p1 - {x, y}]]]]]


Bob Hanlon


On Sat, Jan 14, 2012 at 2:55 AM, Eric Michielssen
<emichiel@eecs.umich.edu> wrote:
> Hello,
>
> I would like to plot/draw a line between two points p1= (x1,y1} and
> p2={x2,y2}, and I would like the line color (preferred) or thickness or dash
> density  to be reflective of a known function f(d) that measures the
> distance d from p1 to the point on the line.
>
> Say p1={x1,y1}={0.,0.}, p2={10.,10}, and f[d_]:=Cos[d].
>
> Is this possible?
>
> Thanks!
> Eric
>
> Eric Michielssen
>

[toc] | [standalone]


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


csiph-web