set term pdf
set output 'tonecurve.pdf'
set size square
set xlabel 'raw brightness'
set ylabel 'jpg brightness'
set y2label 'sample count'
set logscale y2
set title "measured data"
plot \
    'tonecurve.dat' u ($0/65535.0):1 w l t 'L*', \
    '' u ($0/65535.0):2 w l t 'a*', \
    '' u ($0/65535.0):3 w l t 'b*', \
    '' u ($0/65535):4 w l t 'L count' axes x1y2, \
    '' u ($0/65535):5 w l t 'a* count' axes x1y2, \
    '' u ($0/65535):6 w l t 'b* count' axes x1y2
set title "spline fit"
# set logscale xy
plot 'tonecurve.dat' u ($0/65535):1 w l lt 2 t 'L*', 'tonecurve.fit.dat' u 1:2 w l lt 1 t 'fit'
