2

I am trying to do a multiplot. Following are the 4 files that I used with

File1.csv

,col1,col2,col3,col4,col5,col6
10,-39,   0.7,   0,   0,99.3,   0
14,-42,   0.0,   0,   0, 100,   0
42,-64,     0,   0,   0, 100,   0
46,-67,   2.5,   0,   0,97.5,   0
50,-69,   7.6,   0,   0,92.4,   0
54,-75,     0,   0,   0, 100,   0
58,-78,   3.7,   0,   0,96.3,   0
62,-82,  69.0,   0,   0,31.0,   0
66,-85,     0,   0,   0,   0,   0
70,-100,0,0,0,0,0
74,-100,0,0,0,0,0
70,-100,0,0,0,0,0
66,-100,0,0,0,0,0
62,-100,0,0,0,0,0
58,-78,   2.1,   0,   0,97.9,   0
54,-74,   2.9,   0,   0,97.1,   0
50,-69,   2.3,   0,   0,97.7,   0
46,-65,   2.4,   0,   0,97.6,   0
42,-65,     0,   0,   0, 100,   0
14,-43,   1.5,   0,   0,98.5,   0
10,-40,   1.0,   0,   0,99.0,   0

File2.csv

,col1,col2,col3,col4,col5,col6
10,-39,   0.7,   0,   0,99.3,   0
14,-42,   0.0,   0,   0, 100,   0
42,-64,     0,   0,   0, 100,   0
46,-67,   2.5,   0,   0,97.5,   0
50,-69,   7.6,   0,   0,92.4,   0
54,-75,     0,   0,   0, 100,   0
58,-78,   3.7,   0,   0,96.3,   0
62,-82,  69.0,   0,   0,31.0,   0
66,-85,     0,   0,   0,   0,   0
70,-100,0,0,0,0,0
74,-100,0,0,0,0,0
70,-100,0,0,0,0,0
66,-100,0,0,0,0,0
62,-100,0,0,0,0,0
58,-78,   2.1,   0,   0,97.9,   0
54,-74,   2.9,   0,   0,97.1,   0
50,-69,   2.3,   0,   0,97.7,   0
46,-65,   2.4,   0,   0,97.6,   0
42,-65,     0,   0,   0, 100,   0
14,-43,   1.5,   0,   0,98.5,   0
10,-40,   1.0,   0,   0,99.0,   0

File3.csv

,col1,col2,col3,col4,col5,col6
10,-39,   0.7,   0,   0,99.3,   0
14,-42,   0.0,   0,   0, 100,   0
42,-64,     0,   0,   0, 100,   0
46,-67,   2.5,   0,   0,97.5,   0
50,-69,   7.6,   0,   0,92.4,   0
54,-75,     0,   0,   0, 100,   0
58,-78,   3.7,   0,   0,96.3,   0
62,-82,  69.0,   0,   0,31.0,   0
66,-85,     0,   0,   0,   0,   0
70,-100,0,0,0,0,0
74,-100,0,0,0,0,0
70,-100,0,0,0,0,0
66,-100,0,0,0,0,0
62,-100,0,0,0,0,0
58,-78,   2.1,   0,   0,97.9,   0
54,-74,   2.9,   0,   0,97.1,   0
50,-69,   2.3,   0,   0,97.7,   0
46,-65,   2.4,   0,   0,97.6,   0
42,-65,     0,   0,   0, 100,   0
14,-43,   1.5,   0,   0,98.5,   0
10,-40,   1.0,   0,   0,99.0,   0

File4.csv

,col1,col2,col3,col4,col5,col6
10,-39,   0.7,   0,   0,99.3,   0
14,-42,   0.0,   0,   0, 100,   0
42,-64,     0,   0,   0, 100,   0
46,-67,   2.5,   0,   0,97.5,   0
50,-69,   7.6,   0,   0,92.4,   0
54,-75,     0,   0,   0, 100,   0
58,-78,   3.7,   0,   0,96.3,   0
62,-82,  69.0,   0,   0,31.0,   0
66,-85,     0,   0,   0,   0,   0
70,-100,0,0,0,0,0
74,-100,0,0,0,0,0
70,-100,0,0,0,0,0
66,-100,0,0,0,0,0
62,-100,0,0,0,0,0
58,-78,   2.1,   0,   0,97.9,   0
54,-74,   2.9,   0,   0,97.1,   0
50,-69,   2.3,   0,   0,97.7,   0
46,-65,   2.4,   0,   0,97.6,   0
42,-65,     0,   0,   0, 100,   0
14,-43,   1.5,   0,   0,98.5,   0
10,-40,   1.0,   0,   0,99.0,   0

Gnuplot script I got is histogram graph on x1y1 axis and linespoint graph on x2y1 axis

set colors classic
set terminal png notransparent size 1800,640 truecolor medium
set output 'reading.png'
set grid front

set tmargin -1; set bmargin -1
set lmargin -1; set rmargin -1

set style data histogram
set style histogram rowstacked
set style fill solid
set boxwidth 0.5
set datafile separator ","

set xtics axis
set yrange [0:100]
set y2range [-100:-10]
set y2tics
set y2label "Y2Label"
set ylabel "YLabel"
set multiplot layout 4,1 

unset xtics 
unset key
plot for [COL=3:6] 'file1.csv' u COL:xtic(1) axes x1y1 ti col,'' u 2:xtic(1) with linespoint axes x1y2
plot for [COL=3:6] 'file2.csv' u COL:xtic(1) axes x1y1 ti col,'' u 2:xtic(1) with linespoint axes x1y2
plot for [COL=3:6] 'file3.csv' u COL:xtic(1) axes x1y1 ti col,'' u 2:xtic(1) with linespoint axes x1y2
set key below
set xtics
plot for [COL=3:6] 'file4.csv' u COL:xtic(1) ti col,'' u 2:xtic(1) with linespoint axes x1y2

unset multiplot

The resultant graph that I got is having different starting points on x-axis. Can someone please help synchronize histogram and linespoint plots in this.

enter image description here

2
  • 2
    The script you show does not use x2y1, however it does use x1y2. Is this a typo in your question, or your script? The command to make x2 match x1 is set link x2, but if you want x2 to be the same as x1 why not just use x1?
    – Ethan
    Commented May 19, 2020 at 16:53
  • Sorry it is typo. Both are using x1. My question is On x1 axis x1y2 is one position away from x1y1. That can be seen in xtic label.
    – Active Hub
    Commented May 20, 2020 at 4:43

1 Answer 1

1

I can reproduce your result. Right away, I don't know why this shift is happening. Probably something with indexing starting at 0 or starting at 1. Maybe something with the header line or with the histogram style in combination with the linespoints plot.

A possible fix could be using column 0, i.e. ($0-1) (see help pseudocolumns) as x coordinate for the linespoints plot. By the way, you don't have to use xtic(1) mulitple times, it is identical anyway.

Your plot command would shorten to:

plot for [COL=3:6] 'file1.csv' u COL axes x1y1 ti col, '' u ($0-1):2 w lp axes x1y2
plot for [COL=3:6] 'file2.csv' u COL axes x1y1 ti col, '' u ($0-1):2 w lp axes x1y2
plot for [COL=3:6] 'file3.csv' u COL axes x1y1 ti col, '' u ($0-1):2 w lp axes x1y2
set key below
set xtics
plot for [COL=3:6] 'file4.csv' u COL axes x1y1 ti col, '' u ($0-1):2:xtic(1) w lp axes x1y2
1
  • It served the purpose. Thanks a lot.
    – Active Hub
    Commented May 22, 2020 at 17:40

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.