1

I want to make a plot of a file in palette format,

plot 'file.dat' u ($3-$10):($196-$203):($196=$203) pointtype 1 lc palette,\
     'file.dat' u ($7-$14):($200-$207):($200=$207) pointtype 1 lc palette

Whereas the choice of the columns is not regular, I need to use an if condition for the palette axis (bar) which indicates that if column $196=$203 plot column $196 or if $200=$207 plot $200.

I don't know whether this is possible in gnuplot or I should skip using gnuplot.

7
  • I don't what the palette format is. Can you point me to a url or give example data that illustrate the problem? 200+ columns probably mean you should simplify it. gnuplot allows you to select columns by name in case that helps using (column("Age")):(column(1)) Commented Feb 24, 2021 at 9:43
  • If $196=$203 or $200=$207 what do you want to happen in (a) false and (b) true? See stackoverflow.com/questions/14977969/… if you haven't yet. Commented Feb 24, 2021 at 9:46
  • @AllanWind There is no true or false, only choosing the numbers when column 196 is equal to column 203, and when column 200 is equal to column 207. Commented Feb 24, 2021 at 9:57
  • Meaning you want to ignore the data point if $196=$203 or $200=$207? In that case see stackoverflow.com/questions/30359253/… Commented Feb 24, 2021 at 9:58
  • @dove have you checked help ternary? Please specify what should be plotted if $196==$203 and what should be plotted if $196!=$203? Do you want to have a point plotted or not, or just in different color if the condition is met? What do you mean with 3rd axis? Do you want to have a 3D x,y,z plot? Then check help splot. Commented Feb 24, 2021 at 14:19

1 Answer 1

0

From your description I still don't get your point. That's what I've understood so far. You take some operation of some columns to determine the x- and y-coordinates (in your case: $3-$10 and $196-$203). And now, you want to determine the color of the datapoint by what? By some condition? What is the condition? So, what color do you want if the condition is met ($196==$203) and what color do you want to have if the condition is not met (i.e. $196!=$203).

I order to get any further, I made a minimal example with data and with graph. If the value in column 3 is equal to the value in column 4 the color of the datapoint will be according to the palette using column 3, and NaN (= not plotted) otherwise. Is this coming close to what you want to achieve? Maybe we can go on from this...

Code:

### conditional plotting
reset session

$Data <<EOD
1   21  1  0
2   22  2  2
3   23  3  0
4   24  4  4
5   25  5  0
6   26  6  6
7   27  7  0
EOD

set palette rgb 33,13,10

plot $Data u ($1+$2):($3+$4):($3==$4 ? $4 : NaN) w p pt 7 ps 3 lc palette notitle
### end of code

Result:

enter image description here

Sign up to request clarification or add additional context in comments.

2 Comments

your example was exactly what I meant. This solved my problem thank you so much :)
glad to hear we came to a solution. Sometimes is difficult to describe and understand ;-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.