In gnuplot, I use
set style line 11 lc rgb '#222222' lt 1;
set border 3 back ls 11;
set zeroaxis linetype 1 linecolor rgb '#222222';
set xtics axis;
set ytics axis;
set border 0;
set style line 12 lc rgb '#808080' lt 0 lw 1
set grid back ls 12
set xtics add ('' 0)
set ytics add ('' 0)
set xlabel 'x' font 'Times-Italic,14'
set ylabel 'y' rotate by 0 font 'Times-Italic,14'
and this shifts the axis from the border to the 0 values of the axis. However, the xlabel and the ylabel remain at the border, giving them strange position. Is there a generic way of setting the axis labels to the position of the zero values of the axis?
Use generic set label
to position such labels. Then you can use graph
and first
coordinates to position the labels.
y-label: The starting point of the x-axis is at graph 0, first 0
(left-most point of the plot and zero position in y-direction). Now, shift the label by an additional 1 character width to the left with offset char -1,0
and right-align it:
set label 'y' at graph 0, first 0 offset char -1, char 0 right font 'Times-Italic,14'
x-label: The starting point of the y-axis is at first 0, graph 0
. Shift the label by an additional 1 character width to the bottom and center it:
set label 'x' at first 0, graph 0 offset char 0, char -1 center font 'Times-Italic,14'
Note, that with this you must manually make enought space left and below the plot to accomodate the labels, e.g.
set lmargin 3
set bmargin 2
Full example:
reset
set zeroaxis linetype 1 linecolor rgb '#222222'
set xtics axis
set ytics axis
set border 0
set style line 12 lc rgb '#808080' lt 0 lw 1
set grid back ls 12
set xtics add ('' 0)
set ytics add ('' 0)
set label '{/:Italic x}' at first 0, graph 0 offset char 0, char -1 center font 'Times New Roman,14'
set label '{/:Italic y}' at graph 0, first 0 offset char -1, char 0 right font 'Times New Roman,14'
set lmargin 3
set bmargin 2
plot x + 2
Note, that the syntax for getting italic labels was introduced only with version 5.