0

Does anyone know of an easy way to plot, say, sin(x), such that the colour changes depending on the y-value?

set palette defined (0 "blue", 1 "green")
plot sin(x) lc palette frac abs(sin(x))

Also doesn't work!

Any ideas?

Thanks.

Jean-Luc
  • 3,563
  • 8
  • 40
  • 78
  • possible duplicate of [How can I make the line color of a fitted function change with y?](http://stackoverflow.com/questions/22255915/how-can-i-make-the-line-color-of-a-fitted-function-change-with-y) – Christoph Apr 06 '14 at 16:59
  • Sorry I didn't read your comment before posting my answer. Indeed it's the same problem that calls for the same solution... – Pascail Apr 07 '14 at 15:16

1 Answers1

0

You can try to use the special filename '+' to internally generates a list of values (x values as $1) and then use those values to plot what you want using the third column to play with your palette.

set palette defined (0 "blue", 1 "green")
plot '+' u ($1):(sin($1)):(abs(sin($1))) with lines palette

Snapshoot of my solution

Pascail
  • 374
  • 2
  • 11