mas
mas

Reputation: 145

GNUPLOT: boxplots variable line style/colors

I have multiple data files for which I want to draw a single figure. Each of the files contains a column with two variables: true and false. I would like to draw boxplot for each of these values such that they can be compared. Sample of data file is given below:

0.6,true
0.7,true
0.5,false
0.4,true
..

I come up with following code:

plot inputFile1 using (1):($4):(0.3):3  title 'A' , \
inputFile2 using (3):($4):(0.3):3   title 'B' 

This generated the following figure: enter image description here

However, I would like to customize it such that all the boxplots with "true" variable have one specific line style/color and boxplots with "false" variable have another specific line style/color. Furthermore, I would like to show in the title the shape of true and false, however, on x-xis, I want to have File A and B for each true,false pair.

Any help in this regard would be highly appreciated.

Thanks in anticipation.

Upvotes: 1

Views: 510

Answers (1)

Joce
Joce

Reputation: 2332

With your current datafile, you would need to detect whether the second column contains true or false and act accordingly. However, I am not sure gnuplot can process strings from a datafile.

If you process your file and replace the true or false by 1 or 0, then you can adapt the following line:

plot [0:6] "+" using 0:($0/2.):(0.3):0:xtic((int($0)%2)==0?"true":"false") w errorb lc variable

Here the 4th number in the using list defines the colour, with $0 the colour changes for each line of the file, but if the colour number is in one column of your file then use that column. Replace the "+" by your file and the first two numbers in using by the parameters needed by your plotting style. The xtic command processes some column in the file (here the line number $0) and labels the x tic depending on the value (see help ternary).

Note that your MWE does not work as is, please amend it if you want a more precise answer.

Upvotes: 1

Related Questions