Reputation: 61
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.
Upvotes: 2
Views: 139
Reputation: 25734
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
Upvotes: 1