Article 6FDQ1 Conditional line colors in GnuPlot

Conditional line colors in GnuPlot

by
Turbocapitalist
from LinuxQuestions.org on (#6FDQ1)
I'm trying to find a way to have conditional line colors in charts produced by the Gnuplot plotting utility. This is in Gnuplot 5.4 on Raspbian GNU/Linux 11 (bullseye), in case the version is relevant.

The following excerpt produces separate points with the right colors:

Code:plot "datafile.tab" using 1:(column(5) <= 0 ? column(5):1/0) \
with linespoints pt 5 lc rgb "blue" \
title "a label", \
"" using 1:(column(5) > 0 ? column(5):1/0) \
with linespoints pt 5 lc rgb "red" \
title "",But those are only separate points and they remain separate, and not connected by a continuous line as desired. The following is syntactically incorrect but maybe (or maybe not) close to what I'd like to see.

Code:plot "datafile.tab" using 1:5 \
with linespoints pt 8 lw 2 \
lc rgb if ($5 <= 0 ) { "blue" } else { "red" } ) \
title "a label"How can I get Gnuplot to draw a continuous line in two different colors which change depending on which side of a Y-axis threshold the point is?
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments