The R Project SVN R

Rev

Rev 6252 | Rev 6994 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 6252 Rev 6265
Line 2068... Line 2068...
2068
/*  abline(a, b, h, v, col, lty, lwd, ...)
2068
/*  abline(a, b, h, v, col, lty, lwd, ...)
2069
    draw lines in intercept/slope form.  */
2069
    draw lines in intercept/slope form.  */
2070
 
2070
 
2071
SEXP do_abline(SEXP call, SEXP op, SEXP args, SEXP env)
2071
SEXP do_abline(SEXP call, SEXP op, SEXP args, SEXP env)
2072
{
2072
{
2073
    SEXP a, b, h, v, col, lty, lwd;
2073
    SEXP a, b, h, v, untf, col, lty, lwd;
2074
    int i, ncol, nlines, nlty, nlwd;
2074
    int i, ncol, nlines, nlty, nlwd;
2075
    double aa, bb, x[2], y[2];
2075
    double aa, bb, x[2], y[2];
2076
    SEXP originalArgs = args;
2076
    SEXP originalArgs = args;
2077
    DevDesc *dd = CurrentDevice();
2077
    DevDesc *dd = CurrentDevice();
2078
 
2078
 
Line 2093... Line 2093...
2093
    args = CDR(args);
2093
    args = CDR(args);
2094
 
2094
 
2095
    if ((v = CAR(args)) != R_NilValue)
2095
    if ((v = CAR(args)) != R_NilValue)
2096
	CAR(args) = v = coerceVector(v, REALSXP);
2096
	CAR(args) = v = coerceVector(v, REALSXP);
2097
    args = CDR(args);
2097
    args = CDR(args);
-
 
2098
    
-
 
2099
    if ((untf = CAR(args)) != R_NilValue)
-
 
2100
	CAR(args) = untf = coerceVector(untf, LGLSXP);
-
 
2101
    args = CDR(args);
-
 
2102
 
2098
 
2103
 
2099
    PROTECT(col = FixupCol(CAR(args), NA_INTEGER));	args = CDR(args);
2104
    PROTECT(col = FixupCol(CAR(args), NA_INTEGER));	args = CDR(args);
2100
    ncol = LENGTH(col);
2105
    ncol = LENGTH(col);
2101
 
2106
 
2102
    PROTECT(lty = FixupLty(CAR(args), dd->gp.lty));	args = CDR(args);
2107
    PROTECT(lty = FixupLty(CAR(args), dd->gp.lty));	args = CDR(args);
Line 2130... Line 2135...
2130
	    dd->gp.lty = dd->dp.lty;
2135
	    dd->gp.lty = dd->dp.lty;
2131
	GMode(1, dd);
2136
	GMode(1, dd);
2132
	x[0] = dd->gp.usr[0];
2137
	x[0] = dd->gp.usr[0];
2133
	x[1] = dd->gp.usr[1];
2138
	x[1] = dd->gp.usr[1];
2134
	if (R_FINITE(dd->gp.lwd)) {
2139
	if (R_FINITE(dd->gp.lwd)) {
2135
	    if (dd->gp.xlog || dd->gp.ylog) {
2140
	    if (LOGICAL(untf)[0] == 1 && (dd->gp.xlog || dd->gp.ylog)) {
2136
		double xx[101], yy[101];
2141
		double xx[101], yy[101];
2137
		int i;
2142
		int i;
2138
		double xstep = (x[1] - x[0])/100;
2143
		double xstep = (x[1] - x[0])/100;
2139
		for (i = 0; i < 100; i++) {
2144
		for (i = 0; i < 100; i++) {
2140
		    xx[i] = x[0] + i*xstep;
2145
		    xx[i] = x[0] + i*xstep;
Line 2143... Line 2148...
2143
		xx[100] = x[1];
2148
		xx[100] = x[1];
2144
		yy[100] = aa + x[1] * bb;
2149
		yy[100] = aa + x[1] * bb;
2145
		GPolyline(101, xx, yy, USER, dd);
2150
		GPolyline(101, xx, yy, USER, dd);
2146
	    }
2151
	    }
2147
	    else {
2152
	    else {
-
 
2153
		double x0, x1;
-
 
2154
 
-
 
2155
		x0 = ( dd->gp.xlog ) ?  log10(x[0]) : x[0];
-
 
2156
		x1 = ( dd->gp.xlog ) ?  log10(x[1]) : x[1];
-
 
2157
 
-
 
2158
 
2148
		y[0] = aa + dd->gp.usr[0] * bb;
2159
		y[0] = aa + x0 * bb;
2149
		y[1] = aa + dd->gp.usr[1] * bb;
2160
		y[1] = aa + x1 * bb;
-
 
2161
 
-
 
2162
		if ( dd->gp.ylog ){
-
 
2163
		    y[0] = pow(10.,y[0]);
-
 
2164
		    y[1] = pow(10.,y[1]);
-
 
2165
		}
-
 
2166
 
2150
		GLine(x[0], y[0], x[1], y[1], USER, dd);
2167
		GLine(x[0], y[0], x[1], y[1], USER, dd);
2151
	    }
2168
	    }
2152
	}
2169
	}
2153
	GMode(0, dd);
2170
	GMode(0, dd);
2154
	nlines++;
2171
	nlines++;