R作图技巧

1.坐标原点

plot(x, y, xlab="recall", ylab="precision", type="l", lty=1, col=3, xlim=c(0,1), ylim=c(0, 0.04), lab=c(10, 10, 5), las=1, mgp=c(3. 0.5, 0), tck=0.02, xaxs="i", yaxs="i")

xlim:这是x轴数据的边界;

lab:The first two numbers are the desired number of tick intervals on the x and y axes respectively. The third number is the desired length of axis labels, in characters (including the decimal point.)

las=1 :Orientation of axis labels. 0 means always parallel to axis, 1 means always horizontal, and 2 means always perpendicular to the axis.

mgp=c(3. 0.5, 0):Positions of axis components. The first component is the distance from the axis label to the axis position, in text lines. The second component is the distance to the tick labels, and the final component is the distance from the axis position to the axis line (usually zero). Positive numbers measure outside the plot region,
negative numbers inside.

tck=0.02:Length of tick marks, as a fraction of the size of the plotting region. When tck is small (less than 0.5) the tick marks on the x and y axes are forced to be the same size.

yaxs="i" Axis styles for the x and y axes, respectively. With styles "i" (internal) and "r" (the default) tick marks always fall within the range of the data, however style "r" leaves a small amount of space at the edges. (S has other styles not implemented in R.)

要想坐标(0,0)在坐标轴原点,xlim和ylim必须从0开始,xaxs和yaxs也必须是i。




你可能感兴趣的:(R作图技巧)